cedric.v Posted June 19, 2012 Share Posted June 19, 2012 (edited) Hi everyone, I want to change the price of the cart for it to be seen directly on the website without reloading the page. Every time I check or uncheck my checkbox, the price should change. i figured I had to do it with JQuery so this is what I did : For those how might be wondering, the file blockcart.php is loaded because a variable changes and needs to be updated. I haven't called the blockcart.tpl file which shows the content of the variable. PlusQuinze is the name of the checkbox {literal} <script langage="Javascript"> $(document).ready(function($){ $("input").click(function () { $(document).load("./modules/blockcart/blockcart.php"); var name =($(this).attr("name")); if(name == "PlusQuinze") { alert('ok'); var xhr_object = null; if(window.XMLHttpRequest) { // Firefox xhr_object = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer xhr_object = new ActiveXObject('Microsoft.XMLHTTP'); } var method = 'POST'; var filename = './modules/blockcart/blockcart.tpl'; xhr_object.open(method, filename, true); xhr_object.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { if (xhr_object.status == 200) { alert(xhr_object.responseText); } } } xhr_object.send(null); alert('ok'); } }); }); </script> {/literal} There is another solution to my problem which is to refresh directly the blockcart module with a function every time I check my checkbox, like when you add a product to the cart. I'm searching for the function but haven't found it yet. Thank you for your help Edited June 20, 2012 by cedric.v (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts