Glen Glen - 1 year ago 113
jQuery Question

How do i edit 'date' in an edit form using bootstrap and jquery datepicker?

I cant seem to make the 'date' display in an edit form and use datepicker at the same time. Heres the code. I've tried using 'class' and 'id' to call the jquery. Datepicker and php edit form all work fine,,just not in the same value box.

<div class="form-group">
<label class="col-md-4 control-label">Date Agent Instructed</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group" >
<span class="input-group-addon" style="cursor:pointer" > <i class="glyphicon glyphicon-calendar" ></i></span>
<input type="text" style="cursor:pointer" readonly="readonly" name="date_instructed" class="date2" class="form-control" value="<?php echo $row[14];?>" >


Jquery

$(" .date2" ).datepicker({dateFormat:'yy-mm-dd'}); $(".date2").val('');

Answer Source
$(".date2").val('');

This piece of code is emptying your input field. If you want to keep the original value you are echoing into the field via PHP, you will need to remove this piece of jquery code as it is setting the value to nothing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download