i have a product list page, where there is a filter option with some checkboxes, the checkbox filters are working fine, now i used range slider to list products between some price range, below is my code:
my view:
function filterProducts(minPrice, maxPrice) {
var myCheckboxes = new Array();
$("input[name='types[]']:checked").each(function() {
myCheckboxes.push($(this).val());
});
var myCheckboxes1 = new Array();
$("input[name='istyles[]']:checked").each(function() {
myCheckboxes1.push($(this).val());
});
var myCheckboxes17 = new Array();
$("input[name='ocs[]']:checked").each(function() {
myCheckboxes17.push($(this).val());
});
$.ajax({
url: '<?php echo base_url()?>homecontroller/filterpt',
type: 'POST',
data: {
id: <?=$idz?>,
types: myCheckboxes,
istyles: myCheckboxes1,
mstones: myCheckboxes2,
ocs: myCheckboxes17,
minPrice: minPrice,
maxPrice: maxPrice
},
error: function() {
alert('Something is wrong');
},
success: function(data) {
var count = $('.myth').length;
$('#marble').html(data);
$('#count').html(count);
}
});
}
$(document).ready(function() {
$('[name="types[]"], [name="istyles[]"], [name="ocs[]"]').click(function() {
filterProducts(0, 0);
});
});
$(function() {
$("#slider-range").slider({
range: true,
min: 0,
max: 200000,
values: [0, 200000],
slide: function(event, ui) {
$("#amount").val("₹" + ui.values[0] + " - ₹" + ui.values[1]);
filterProducts(ui.values[0], ui.values[1]);
}
});
$("#amount").val("₹" + $("#slider-range").slider("values", 0) +
" - ₹" + $("#slider-range").slider("values", 1));
});
my controller:
public function filterpt() {
$types=$this->input->post('types');
$istyles=$this->input->post('istyles');
$ocs=$this->input->post('ocs');
$id=$this->input->post('id');
$min=$this->input->post('minPrice');
$max=$this->input->post('maxPrice');
$data = $this->product->filterpt($types,$istyles,$ocs,$id,$min,$max);
my model:
function filterpt($types,$istyles,$ocs,$id,$min,$max)
{
$this->db->where('types', $id);
$this->db->where("status", "Active");
if($min >0 || $max >0)
{
$this->db->where('jrp >= ',$min);
$this->db->where('jrp <= ',$max);
}
if(isset($istyles)){
$this->db->where_in('istyles', $istyles);
}
}
this is my live url:live
however the range slider doesnt show results based on the prices selected, there is some issue going in front end, coz even when i comment the min max where condition in model, the range slider shows random products on selection. can anyone please tell me what is wrong in here.