I have 3 HTML Elements
<input id = "startdate" name = "startdate" type="text" class="datepicker form-control" placeholder="Start Date...">
<input id = "enddate" name = "enddate" type="text" class="datepicker form-control" placeholder="End Date...">
<button class="btn btn-block btn-lg btn-primary waves-effect" id="btngenerate" name="btngenerate">Generate FSP Report</button>
and a qry_vsr.php
<?php
require 'conn.php';
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
$sql = 'My Query Here with the parameter'
$result = mysqli_query($con, $sql);
while ($array = mysqli_fetch_row($result)) {
echo 'Create Table';
}
mysqli_close($con);
?>
Now I call this php file in include in a table
<table id="dtable" name="dtable" class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead id="thead" name="thead">
<tr>
<th>Table Headers Here</th>
</tr>
</thead>
<tbody id = "tblreport">
<?php include('../../php/pages/sfa/qry_vsr.php') ?>
</tbody>
</table>
Now here is my question.
How can I pass those element value in the qry_vsr.php without refreshing or going to blank page and populate data in this php include inside the table?
here is the ajax
$(document).ready(function () {
$('#btngenerate').click(function (e) {
var d1 = $('#startdate').val();
var d2 = $('#enddate').val();
var fspcode = $('#fspcode').find(":selected").text();
var count = 0;
var i;
var x;
if (d1 == "" || d2 == "" || fspcode == "Nothing Selected") {
sfaMsgbox('Please provide proper date range and select FSP.');
} else if (d2 < d1) {
sfaMsgbox('Improper date range.');
} else {
$.ajax({
url: '../../php/pages/sfa/qry_vsr.php',
type: "POST",
datatype: 'json',
data: ({
startdate: d1,
enddate: d2,
fsp: fspcode
})
});
}
});
});
ajaxit will help you.