[英]filter by slider range
While using price range slider It shows me all data according to price... thats fine 使用价格范围滑块时,它会根据价格向我显示所有数据。
But, when I already select city for ex. 但是,当我已经选择城市作为前任。 Delhi. 德里。 Then I want to see price range according to Delhi only 然后我只想看根据德里的价格范围
after selecting dropdown how its look 选择下拉菜单后的外观
but then I dragging price range filter It giving other city detail also. 但随后我拖动了价格范围过滤器,它也提供了其他城市的详细信息。 That I don't want to see. 我不想看到的。
for example 例如
My code begins here, 我的代码从这里开始
My model 我的模特
public function ajax($size = '',$sprice = '',$eprice = '')
{
$query = "SELECT * from info_user Where user_status ='1'";
if(!empty($size)){
$query .= " and city in('".$size."')";
}
if(!empty($sprice) && !empty($eprice)){
$query .= " and charge_per_hour >='".$sprice."' and charge_per_hour <='".$eprice."'";
}
$result = $this->db->query($query);
return $result->result();
}
My ajax price range filter code 我的Ajax价格范围过滤器代码
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 1000,
max: 4000,
values: [ 500, 4000 ],
slide: function( event, ui ) {
$( "#priceshow" ).html( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
$( ".price1" ).val(ui.values[ 0 ]);
$( ".price2" ).val(ui.values[ 1 ]);
$('.product-data').html('<div id="loaderpro" style=""></div>');
$.ajax({
url:"http://localhost/Speakertest/index.php/welcome/ajax",
type:'post',
data:{size:size,sprice:$(".price1" ).val(),eprice:$( ".price2" ).val()},
success:function(result){
$('.product-data').html(result);
}
});
}
});
$( "#priceshow" ).html( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});
This is code of dropdwon filter If you want to see 这是dropdwon过滤器的代码如果您想看
var size;
$(function(){
$('.item_filter').change(function(){
$('.product-data').html('<div id="loaderpro" style="" ></div>');
var size = $(this).find(":selected").val();
$.ajax({
url:"http://localhost/Speakertest/index.php/welcome/ajax",
type:'post',
data:{size:size,sprice:$(".price1" ).val(),eprice:$( ".price2" ).val()},
success:function(result){
$('.product-data').html(result);
}
});
});
});
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 1000,
max: 4000,
values: [ 500, 4000 ],
slide: function( event, ui ) {
$( "#priceshow" ).html( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
$( ".price1" ).val(ui.values[ 0 ]);
$( ".price2" ).val(ui.values[ 1 ]);
$('.product-data').html('<div id="loaderpro" style=""></div>');
//EDITED PART
var size = $(this).find(":selected").val();
$.ajax({
url:"http://localhost/Speakertest/index.php/welcome/ajax",
type:'post',
data:{size:size,sprice:$(".price1" ).val(),eprice:$( ".price2" ).val()},
success:function(result){
$('.product-data').html(result);
}
});
}
});
$( "#priceshow" ).html( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});
EDIT: I've made mistake while copy/pasting your code 编辑:复制/粘贴您的代码时,我犯了错误
REPLACE THIS: 替换此:
var size = $(this).find(":selected").val();
TO: 至:
var size = $('.item_filter').find(":selected").val();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.