I'm sure this is something really simple that I'm missing, but I'm having difficulty setting a hidden input value.
My form looks like this
<?php echo validation_errors(); ?>
<?php echo form_open('purchasing'); ?>
<h1>Purchasing Reports</h1>
<div class="input-group">
<input type="text" class="form-control daterange">
<input type="hidden" id="startDate" name="startDate" value="" />
<input type="hidden" id="endDate" name="endDate" value="" />
<span class="input-group-btn">
<button class="btn btn-primary" type="submit">Submit ></button>
</span>
</div>
<?php echo form_close(); ?>
And my JS like this
$( "#purchasing" ).submit(function( event ) {
event.preventDefault();
var dateArray = $( ".daterange" ).val().split(" - ");
var startDate = new Date(dateArray[0]);
var startDateFormatted = moment(startDate).add('s', 10).format();
document.getElementById("startDate").value = startDateFormatted
var endDate = new Date(dateArray[1]);
var endDateFormatted = moment(endDate).add('s', 10).format();
$( "#endDate" ).val( endDateFormatted );
});
As you can see the date range picker formats the start and end dates into the correct format, then is supposed to pass them into the hidden form values for processing. If I alert the value of that hidden value I do get the correct response, but it doesn't get passed through to the controller.
As you can see I have tried both the jQuery and Javascript versions of passing the value to the inputs, but neither seem to make a difference.
I have also been through all the answers in this post, with no luck