I'm using bootstrap and jquery to make a form that searches a database using a php file, I managed to add filters without issue, my problem is that now I've added a Date Picker using Bootstrap-DateTimePicker, while there is no problem with the displaying of the date in the form, I cannot seem to be able to get the actual string of the date as a variable into my php file.
This is the Form HTML right now:
<form id="buscarInv" action="index.php" method="post" class="navbar-form pull-left" role="search">
<div class="form-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Filtrar</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" id="search-filter" role="menu">
<?php print("$salida");?>
</ul>
<input type="hidden" name="search_param" value="" id="search_param">
<input type="text" class="form-control" name="searchinv" placeholder="Buscar" onkeydown="searchq();">
</div>
</div>
<div class='input-group date' name='datetimepicker1' id='datetimepicker1'>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span> Date
</span>
<input type='text' data-date-format="YYYY-MM-DD" class="form-control" placeholder="Fecha" name="fechaC" id="fechaC">
</div>
</form>
And here's the DateTimePicker script and the script to send the inputs to the php file. DateTimePicker:
$(function () {
$('#datetimepicker1').datetimepicker({format: 'YYYY-MM-DD'});
});
Search:
function searchq(){
var searchTxt = $("input[name='searchinv']").val();
var filter = $("input[name='search_param']").val();
var fechaEnv = $("input[name='fechaC']").val();
$.post("search.php",{searchVal: searchTxt, filter:filter, fechaEnv:fechaEnv}, function(output){
$("#output").html(output);
});
}
I've tried using name='datetimepicker1', tried to set the value of fechaC in the datetimepicker function, but nothing appears to work, am I missing something?
UPDATE: Added the PHP
$output='<thead>
<tr>
<th>Producto</th>
<th>Cantidad</th>
<th>Precio</th>
<th>Locacion</th>
<th>Fecha</th>
</tr>
</thead>
<tbody>';
$idcat='';
$fechaT = date('Y-m-d');
if(isset($_POST['searchVal'])){
$searchq = $_POST['searchVal'];
if(isset($_POST['fechaEnv'])){
$fechaT = $fechaEnv;
$output .= '<tr><td>Date should be displayed here: '.$fechaEnv.'</td></tr>';
}
Yet when I echo the output it shows up as: "Date should be displayed here:" without adding the date
Forgot collect fechaEnv like $_POST, $fechaEnv= $_POST['fechaEnv'];.
if(isset($_POST['fechaEnv'])){
//$fechaT = $fechaEnv;
$fechaEnv= $_POST['fechaEnv'];
$output .= '<tr><td>Date should be displayed here: '.$fechaEnv.'</td></tr>';
}