php - How to add plus + and minus - button in quantity box of product listing page (list.phtml) -


below code,

<?php if($_product->issaleable()): ?> <script type="text/javascript"> function setqty(id, url) {     var qty = document.getelementbyid('qty_' + id).value;     document.getelementbyid('cart_button_' + id).innerhtml = '<button type="button" class="button" onclick="setlocation(\'' + url + 'qty/' + qty + '/\')"><span><span>add cart</span></span></button>';    } </script> <label for="qty"><?php echo $this->__('qty:') ?></label> <input type="text" name="qty_<?php echo $_product->getid(); ?>" id="qty_<?php echo $_product->getid(); ?>" maxlength="12" value="1" onkeyup="setqty(<?php echo $_product->getid(); ?>, '<?php echo $this->getaddtocarturl($_product) ?>');" title="<?php echo $this->__('qty') ?>" class="input-text qty" /> <span id="cart_button_<?php echo $_product->getid(); ?>"><button type="button" class="button" onclick="setlocation('<?php echo $this->getaddtocarturl($_product) ?>')"><span><span><?php echo $this->__('add cart') ?></span></span></button></span>   <?php else: ?> 

the above code replaced previous code(below code)

<?php if($_product->issaleable()): ?> <button type="button" class="button" onclick="setlocation('<?php echo $this->getaddtocarturl($_product) ?>')"><span><span><?php echo $this->__('add cart') ?></span></span></button> <?php else: ?> 

now adding quantity cart have put manually box, want add + , - button increasing , decreasing quantity, should do. tried lots of things not working here.

if there no spacial design require can try input type "number" instead of "text", field increase , decrease button comes in input box.

http://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_number

<input type="number" name="qty_<?php echo $_product->getid(); ?>" id="qty_<?php echo $_product->getid(); ?>" maxlength="12" value="1" onkeyup="setqty(<?php echo $_product->getid(); ?>, '<?php echo $this->getaddtocarturl($_product) ?>');" title="<?php echo $this->__('qty') ?>" class="input-text qty" /> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -