Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
458 rajveer 1
/* 
2
     Author: Binay Kumar
3
     Created on: 30.09.2010
4
 
5
     addResearch(refdivid,reqtype) refdivid=pane1, reqtype=single/multi
6
     Multiple request: onclick="javascript:addResearch('pane2','multi');"
7
     Single request: onclick="javascript:addResearch('','single');"
8
 
9
     addToCart(refdivid,reqtype) refdivid=pane1, reqtype=single/multi
10
     Multiple request: onclick="javascript:addToCart('pane2','multi');"
11
     Single request: onclick="javascript:addToCart('','single');"
12
 
13
*/
14
function addResearch(refdivid,reqtype){
15
     var tmp_resp='<TABLE cellspacing="1" cellpadding="0" border="0" width="100%" id="22"><TR><TD><INPUT type="checkbox" name="research" value="22" id="check2"></TD><TD><img src="images/p2.gif" width="60" height="60" /></TD><TD><DIV><A href="#">Nokia N-96</A><SPAN class="text">Price: Rs. 39,999</SPAN><SPAN class="text">3 Megapixel Camera Dual LED Flash</SPAN></DIV></TD></TR></TABLE>';
16
     var research_tot=$("#research_total").val();
17
     var seldata="";
18
     var tot=0;
19
     var saprt="";
20
 
21
     if(reqtype=="multi"){
22
          var containerdiv = "#" + refdivid;     
23
          var par= containerdiv + " input[type=checkbox]:checked";
24
          $(par).each(function(){
25
               saprt = (tot>0)? "_":"";
26
               seldata += saprt+$(this).val();
27
               tot++
28
          });
29
     }else{
30
          var seldata=$("#item_id").val();
31
          var tot=1;
32
     }
33
 
34
     if(tot>0){
35
          alert("AJAX request to add products in My research. Product ID: "+seldata+" and total: "+tot);
36
          jQuery.ajax({
37
               type: "POST",
38
                      url: "../myresearch",
39
                      data: "productid="+seldata,
40
                      success: function(msg){
41
 
42
                           if(msg == 0){
43
                                alert( "Please register/signin to use myresearch tool" );
44
                           }else if(msg == 1){
45
                                alert( "Product is already in my research" );
46
                           }else {
47
                                var t=(research_tot*1)+(tot*1);
48
                                $("#research_total").val(t);
49
                                if(t > 0){
50
                                     $("#research_default").css("display","none");
51
                                }     
52
                                $("#pane1").prepend(msg);
53
                                $('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
54
 
55
                                if(reqtype == "multi"){
56
                                     var arrayprod_id=seldata.split("_");
57
                                     jQuery.each(arrayprod_id,function(intIndex, objValue){
58
                                          var tblid="#pane1 #"+objValue+ " td";
59
                                          $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
60
                                          $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');     
61
 
62
                                     });
63
 
64
                                }else{
65
                                     var tblid="#pane1 #"+seldata+ " td";
66
                                     $(tblid).animate({ backgroundColor: "#fcffb3" }, 'slow');
67
                                     $(tblid).animate({ backgroundColor: "#F5F5F5" }, 'slow');  
68
                                }
69
 
70
                           }
71
 
72
                           alert( "Data Saved: " + msg );
73
 
74
                      }
75
          });
76
 
77
     }else{
78
          alert("Please select atleast one product");
79
     }
80
}
81
 
82
 
83
function addToCart(refdivid,reqtype){
84
     var seldata="";
85
     var tot=0;
86
     var saprt="";
87
     if(reqtype == "multi"){
88
          var containerdiv = "#" + refdivid;
89
          var par= containerdiv + " input[type=checkbox]:checked";
90
          $(par).each(function(){
91
               saprt = (tot>0)? "_":"";
92
               seldata += saprt+$(this).val();
93
               tot++
94
          });
95
     }else{
96
          seldata = $("#item_id").val();
97
          tot=1;
98
     }
99
     alert(seldata);
100
 
101
     if(tot>0){
102
          alert("AJAX request to add products in Cart. Product ID: "+seldata+" and total: "+tot); 
103
          jQuery.ajax({
104
               type: "POST",
105
                      url: "../cart",
106
                      data: "productid="+seldata,
107
                      success: function(msg){
108
                           $("#cartItemCount").html(msg*1);
109
                           alert( "Data Saved: " + msg );
110
                      }
111
          });
112
     }else{
113
          alert("Please select atleast one product");
114
     }
115
 
116
}