javascript - Adding increment to form input getting TypeError: qty_el is null -
i´m trying add increments in magento grouped items, code should follows javascript returning typeerror: qty_el null. think problem should when pass element id variable, can´t solve this. missing? there way this? hope me.
<div class="add-to-cart"> <div class="qty-button form-group"> <input type="text" name="super_group_<?php echo $_item->getid() ?>" id="super_group_<?php echo $_item->getid() ?>" maxlength="12" value="<?php echo $_item->getqty() * 1 ?>" title="<?php echo mage::helper('core')->quoteescape($this->__('qty')) ?>" class="input-text qty group-qty form-control" /> <div class="box-container"> <div class="box-icon button-plus"> <input type="button" onclick="incre(2,'super_group_<?php echo $_item->getid() ?>')" class="qty-increase" /> </div> <div class="box-icon button-minus"> <input type="button" onclick="decre(<?php echo json_encode ($i);?>,'super_group_<?php echo $_item->getid() ?>')" class="qty-decrease" /> </div> </div> </div> </div> <script type="text/javascript"> function incre(qty_inc,idname) { var qty_el = document.getelementbyid(idname); var qty = qty_el.value; if( !isnan( qty )){ if(qty_inc>0){ qty_el.value = number(qty) + qty_inc ; } else { qty_el.value++; } } } function decre(qty_inc,idname) { var qty_el = document.getelementbyid(idname); var qty = qty_el.value; if(!isnan( qty ) && qty > '0') { if(qty_inc>0){ qty_el.value = number(qty) - qty_inc; } else { qty_el.value--; } } }
you can try way increment decrement quantity on grouped products
<label for="qty"><?php echo $this->__('quantity:') ?></label> <a href="javascript:void(0);" onclick="var qty_el = document.getelementbyid('super_group_<?php echo $_item->getid(); ?>'); var qty = qty_el.value; if( !isnan( qty ) && qty > 1 ) qty_el.value--;return false;" class="qty-decrease" > - </a> <input type="text" pattern="\d*" name="super_group[<?php echo $_item->getid() ?>]" id="super_group_<?php echo $_item->getid(); ?>" maxlength="12" value="<?php echo max($this->getproductdefaultqty() * 1, 1) ?>" title="<?php echo $this->__('quantity') ?>" class="input-text qty" /> <a href="javascript:void(0);" onclick="var qty_el = document.getelementbyid('super_group_<?php echo $_item->getid(); ?>'); var qty = qty_el.value; if( !isnan( qty )) qty_el.value++;return false;" class="qty-increase" /> + </a>
Comments
Post a Comment