I have tried various solutions but all are working if i used with submit button. But I need a solution- passing value to php POST/GET(method) with jquery submit only. Thanks in advance.
if(isset($_POST['submit']))
{
mysql_real_escape_string($_POST['amount']);
$values = str_replace(' ','',$_POST['amount']);
$values = str_replace('$','',$values);
$values = explode('-',$values);
$min = $values[0];
$max = $values[1];
$select_min_value = $_POST['select_min_value'];
$select_max_value = $_POST['select_max_value'];
$res = mysql_query('select id,name,image,price,discount from products where price BETWEEN "'.$select_min_value.'" AND "'.$select_max_value.'"');
$count = mysql_num_rows($res);
$HTML='';
if($count > 0)
{
while($row=mysql_fetch_array($res))
{
code;
}
}
else {
$HTML ='no products';
}}
else{
$min =0;
$max=35000;
$HTML='search products';
}
echo $HTMl;
My javascript code
<script>
$(function () {
$("#slider-range").slider({
range: true,
min: 0,
max: 350000,
values: [ <?php echo $min; ?>, <?php echo $max; ?> ],
slide: function (event, ui) {
$("#amount").val("$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ]);
var select_min_value = ui.values[ 0 ];
var select_max_value = ui.values[ 1 ];
$("#amount_txt").val(select_min_value + '-' + select_max_value);
$("#filter_min_price").text("$" + select_min_value);
$("#filter_max_price").text("$" + select_max_value);
},
change: function (event, ui) {
var select_min_value = ui.values[ 0 ];
var select_max_value = ui.values[ 1 ];
alert(select_min_value);
alert(select_max_value);
$('#filter_product').trigger('submit',['select_min_value','select_max_value']);
}
});
$("#amount").val("$" + $("#slider-range").slider("values", 0) +
" - $" + $("#slider-range").slider("values", 1));
});
</script>
HTML form
<form action="filter.php" id="filter_product" name="filter_product" method="post" accept-charset="utf-8">
<div id="slider-range"></div>
<div class="range_cont clearfix">
<div class="pull-left" id="filter_min_price">$<?php echo $min; ?></div>
<div class="pull-right" id="filter_max_price">$<?php echo $max; ?></div>
</div>
<input type="hidden" name="submit" id="submit" />
</form>