this is the code i tried:
function show(date,meal){
var parameters = 'q='+date '&m='+meal;
var argUrl = 'meal1.php';
$.ajax({
url: argUrl,
type: 'POST',
data: parameters,
success: function (str) {
$('#txtHint').html(str);
//alert(parameters);
}
});
}
My form:
<form method="post">
<input type="text" id="datewise" name="datewise" value="" class="form- control input-datepicker-close" placeholder="dd/mm/yy" >
<select id="mealplan" name="mealplan" class="form-control" onchange="shownoofroom(this.value);">
<option value=""> Select </option>
<?php $sql = "select *from mean_plan";
$retval = mysql_query( $sql, $conn );
if(! $retval ){
die('Could not get data: ' . mysql_error());
echo 'Could not get data: ' . mysql_error();
}
while($row = mysql_fetch_array($retval,MYSQL_ASSOC)){ //roll id if
//$roll_id= $row['roleid'];
?>
<option value="<?php echo $row['meanplan']?>"><?php echo $row['meanplan']?></option>
<?php
}
?>
</select>
<input type="buttton" class="btn btn-info btn-primary " onclick="show('<?php $_POST['datewise'];?>','<?php $_POST['mealplan'];?>')name="submit">
</form>
<div id="txtHint">
Is this the correct method to pass parameters to a function.. Or else how i can pass form values in the onclick event and store it in function variable.