Joomla!

this.parentNode.elements is undefined when updating Quantities in Virtuemart

Written by Ian Carnaghan · 40 sec read >

To solve this problem open the following file

components/com_virtuemart/js/themes/default/templates/product_details/includes/quantity_box_general.tpl.php

and in line 46 and 47 remove this code 

<input type="button" class="quantity_box_button quantity_box_button_up" onclick="var qty_el = this.parentNode.elements[\'quantity[]\']; var qty = qty_el.value; if( !isNaN( qty )) qty_el.value++;return false;" />
 
<input type="button" class="quantity_box_button quantity_box_button_down" onclick="var qty_el = this.parentNode.elements[\'quantity[]\']; var qty = qty_el.value; if( !isNaN( qty ) && qty > 0 ) qty_el.value--;return false;" />

and replace it with this code

<input type="button" class="quantity_box_button quantity_box_button_up" onclick="var qty_el = document.getElementById(\'quantity'.$prod_id.'\'); var qty = qty_el.value; if( !isNaN( qty )) qty_el.value++;return false;" />
 
<input type="button" class="quantity_box_button quantity_box_button_down" onclick="var qty_el = document.getElementById(\'quantity'.$prod_id.'\'); var qty = qty_el.value; if( !isNaN( qty ) && qty > 0 ) qty_el.value--;return false;" />

Last Updated On March 25, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. Profile

Leave a Reply

avatar
  Subscribe  
Notify of