Glen Glen - 1 year ago 110
PHP Question

Edit form not working with bootstrap and datepicker

I ve created an edit form CRUD system. It all works well apart from when i want user to be able to edit the date in the form.

The code below is the only way i can get the whole thing working with jquery datepicker, bootstrap and php. At moment the php sits outside the field i want to edit.

So, the datepicker works fine (id=date2) . if i delete the datepicker and give the php a 'value' the date appears in the field ready to be edited but the datepicker obviously doesn't work as ive taken it out of the code.

If i mix the 2 then the php doesn't call the date value into the text field, but the date picker works.

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

<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" placeholder="Click Here To Edit" readonly="readonly" name="date_instructed" id="date2" class="form-control" > <?php echo $row[14];?>

Answer Source

$(".date2").val(''); This piece of code (which was in my js 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.

Symeon Quimby answered it on a related question,

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