var maxpage php echo maxpage var loading false var clear true filform

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var maxpage=<?php echo $maxpage;?>;
var loading=false;
var clear=true;
$("#filform").on("change","input[type=checkbox]", function()
{
var ch = $("#filform").find("input[type=checkbox]:checked");
var check=new Array();
ch.each(function()
{
var value=$(this).val();
var attr=$(this).parent().find("input[type=checkbox]").attr("name");
attr=attr.replace(/[^0-9]/g,"");
check.push({"attr":attr, "value":value});
});
if(clear==true)
{
$("#pageid").val(1);
}
var param=$("#filform").serialize();
$.ajax(
{
type: "POST",
url: "/php/ajax/filter.php",
data: param,
dataType: "JSON",
success: function(data)
{
$("ul.filter").empty();
if(clear==true)
{
$("div.productrow").empty();
}
$("<p>").attr("class","params").html("Параметры").appendTo("ul.filter");
$("<p>").attr("id","filteroff").html("Сбросить фильтр").appendTo("ul.filter");
var i=1;
$(data[0]).each(function()
{
var li=$("<li>");
var id=this.id;
var at=this.attr;
var atval=this.value;
$("<span>").attr("class","f_name").html(at).appendTo(li);
var div=$("<div>").attr("class","filterbox").appendTo(li);
$(atval).each(function(val, el)
{
if (xxx(id,el,check))
$("<input>").attr({"type":"checkbox", "id":"p_"+i+"","name":"param["+id+"][]","value":""+el+"","checked":"checked"}).appendTo(div);
else
$("<input>").attr({"type":"checkbox", "id":"p_"+i+"","name":"param["+id+"][]","value":""+el+""}).appendTo(div);
$("<label>").attr("for","p_"+i+"").html(el).append("<br>").appendTo(div);
i++;
});
$(li).appendTo("ul.filter");
});
$(data[1]).each(function()
{
var div=$("<div>").attr("class","productleft").hide();
var a=$("<a>").attr({"href":"/catalog/goods"+this.id+".html", "target":"_blank"});
$("<h3>").html(this.name).appendTo(a);
$("<img>").attr("src","/img/catalog/small/"+this.preview).appendTo(a);
$("<p>").html("Цена: <span>"+this.price+" руб.</span>").appendTo(a);
if(this.status ==1)
{
$("<img>").attr({"class":"new","src":"/img/new.png"}).appendTo(a);
}
a.appendTo(div);
div.appendTo("div.productrow").fadeIn();
});
maxpage=data[2];
loading = false;
clear=true;
if(parseInt($("#pageid").val()) == maxpage)
{
$("#bottom").hide();
}
else
$("#bottom").show();
}
});
});