aivanovas Posted May 4, 2011 Share Posted May 4, 2011 Hi, I am trying to figiure out why Ajax pop-up window not works with radio button (<input type="radio" onclick="submit()" >). But it works with input type=submit value=value="<?php echo $VM_LANG->_('PHPSHOP_CART_ADD_TO') ?> ). If There is button when user click on it the pop-up messege will come up and user stays at the same webpage. ut with radio button ofter Click user is redirected to the Virtuemart shopping cart but I wish that Ajax pop-up windows will comeup. I posted few topics on Virtuemart forum about it but no advices in there. The code is: <form action="<?php echo $mm_action_url ?>index.php" method="post" name="addtocart" id="<?php echo uniqid('addtocart_') ?>" class="addtocart_form" <?php if( $this->get_cfg( 'useAjaxCartActions', 1 ) && !$notify ) { echo 'onsubmit="handleAddToCart( this.id );return false;"'; } ?>> <?php } echo $html; if (USE_AS_CATALOGUE != '1' && $product_price != "" && !stristr( $product_price, $VM_LANG->_('PHPSHOP_PRODUCT_CALL') )) { ?> <?php if ($children != "multi") { ?> <div style="float: right;vertical-align: middle;"> <?php if ($children == "drop") { echo $ps_product_attribute->show_quantity_box($product_id,$product_id); } if ($children == "radio") { echo $ps_product_attribute->show_radio_quantity_box(); } $button_lbl = $VM_LANG->_('PHPSHOP_CART_ADD_TO'); $button_cls = 'addtocart_button'; if( CHECK_STOCK == '1' && !$product_in_stock ) { $button_lbl = $VM_LANG->_('VM_CART_NOTIFY'); $button_cls = 'notify_button'; } ?> <input type="radio" onclick="submit()" value="<?php echo $VM_LANG->_('PHPSHOP_CART_ADD_TO') ?> /> </div> <?php } ?> <input type="hidden" name="flypage" value="shop.<?php echo $flypage ?>" /> <input type="hidden" name="page" value="shop.cart" /> <input type="hidden" name="manufacturer_id" value="<?php echo $manufacturer_id ?>" /> <input type="hidden" name="category_id" value="<?php echo $category_id ?>" /> <input type="hidden" name="func" value="cartAdd" /> <input type="hidden" name="option" value="<?php echo $option ?>" /> <input type="hidden" name="Itemid" value="<?php echo $Itemid ?>" /> <input type="hidden" name="set_price[]" value="" /> <input type="hidden" name="adjust_price[]" value="" /> <input type="hidden" name="master_product[]" value="" /> Maybe somebody has a suggestion why Ajax not works with radio button, I understand that there is something related to onclick="submit()" . Thanks andd regards Quote Link to comment Share on other sites More sharing options...
aivanovas Posted May 4, 2011 Author Share Posted May 4, 2011 Or it would be nice that it will stay on the same page. I tried to make <form action="#" but it not works Quote Link to comment Share on other sites More sharing options...
aivanovas Posted May 4, 2011 Author Share Posted May 4, 2011 Or it would be nice that it will stay on the same page. I tried to make <form action="#" but it not works AJAX scirpt is this one <script type="text/javascript"> $(document).ready(function() { // generate markup $("div.AJAX_field").each(function() { //$(this).append("pid: "+$(this).parent().attr("pid")+" field: "+$(this).attr("field")+ " title: "+$(this).attr("title")+" content: "+$(this).attr("content")); $(this).append($(this).attr("title")+": <input type=\"text\" value=\""+$(this).attr("content")+"\"/><input class=\"AJAX_go\" value=\"Do\" type=\"submit\"><div class=\"AJAX_response\"></div>"); // for each one, add text box, button // with correct sku, field, etc }); $("div.AJAX_detail_link").each(function() { $(this).html("<a href=\""+$(this).attr("href").replace(/shop.product_details/i, 'product.product_form')+"\">Details</a>"); }) $(".AJAX_go").click(function() { // send request // $(this).next().html("<img src=\"/modules/mod_vm_ajax_update/images/loading.gif\"/> Updating"); $pid = $(this).parent().parent().attr("pid"); // send update $.ajax({ type: "POST", timeout: 2000, url: "/modules/mod_vm_ajax_update/AJAX/AJAXupdate.php", data: {sku: $pid, field: $(this).parent().attr("field"), content: $(this).prev().attr("value")}, success: function(xml) { // get results and update content $("div.AJAX[@pid="+$("sku", xml).text()+"] > div.AJAX_field[@field="+$("field", xml).text()+"] :text").val($("content", xml).text()); $("div.AJAX[@pid="+$("sku", xml).text()+"] > div.AJAX_field[@field="+$("field", xml).text()+"] > div.AJAX_response").html("Updated."); } // no point in error as we couldn't find the div anyway }); }); }); < Quote Link to comment Share on other sites More sharing options...
aivanovas Posted May 5, 2011 Author Share Posted May 5, 2011 Probably my problem descrition is not so good. Please let me know if I should post more details about hte problem. But problem is Ajax related. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.