Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandan's avatar
Level 13

input type datetime-local jquery not working on set attribute

hii when i set attribute on eventdate in edit modal popup then datetime-local input type not set how to do it not working on edit modal popup (#edit-eventDate)

here is my code

function setAttrValue(data){
	var eventId = $(data).attr('data-id');
	$("#eventId").attr('value', eventId);
	var getUrl = "{{url('/event/edit')}}";
	$.ajax({
    	url: getUrl,
    	type: "GET",
    	dataType: 'json',
    	data:{
        	id: eventId
    	},
    	success: function(response){
        	$("#edit-eventName").val(response.data.event_name);
        	$("#edit-eventDate").val(response.data.event_date);
        	$("#edit-description").val(response.data.description);
        	$("#view_policy").attr('href', response.data.file_url);
    	}
	});

}

0 likes
4 replies
Sinnbeck's avatar

Can you show the html for the `#edit-eventDate'

vandan's avatar
Level 13

@sinnbeck sure sir

	<div class="row mb-4">
   		<label for="status" class="col-sm-3 col-form-label">Event Date</label>
        		<div class="col-sm-9">
                		<input class="form-control" type="datetime-local" id="edit-eventDate" name="event_date">
                </div>
    </div> 		
Sinnbeck's avatar

And when you say it isnt working. What happens? No date in the input? Or wrong date? Or an error?

Are you using any date picker libraries on the input field?

vandan's avatar
Level 13

@sinnbeck no sir i cannot use any datepicker libraries my point is i have create edit modal popup then i set attributes on edit modal popup so when i click on edit modal then display value on edit mode eventname, description other are working fine but datetime-local cannot set on edit modal popup

Please or to participate in this conversation.