Reputation: 2970
I have a form where Date needs to loaded from saved values in database for a particular event.
Laravel is submitting correct date to the form. It returns [{"Date":"2016-09-15"}]
Here is my code:
$('#ActDate').empty();
$.each(data, function (index, day){
$('#ActDate').append('<input value="' + day.Date '"/>');
});
<div class="form-group">
<label align="right" for="Date" class="control-label col-xs-2">Date : </label>
<input type="date" class="col-xs-3" id="ActDate" name="ActDate" value="">
</div>
In console this error message is shown
Uncaught SyntaxError: missing ) after argument list
Its near $('#ActDate').append('<input value="'+day.Date'"/>');
this line.
I have beginner level knowledge about JavaScript.
How to fix this problem?
Upvotes: 1
Views: 92
Reputation: 2825
You have a syntax error:
"'+day.Date'"
is missing the second '+' sign
should be: "'+day.Date+'"
Upvotes: 1
Reputation: 2464
You can not add input field in new input field. you have to write like below code
$('#ActDate').val(day.Date);
Upvotes: 1