News:

Looking for documentation? Take a look on our wiki

Main Menu

[SOLVED] Quantity combobox in cart

Started by anekro, March 18, 2013, 20:20:08 PM

Previous topic - Next topic

anekro

i'm trying to use comboboxes for quantity in Virtuemart instead of quantity text and update button.

When i have only one article in the cart it works perfectly, but when i have more than one, it's not working.

Here's the form code

<form action="<?php echo JRoute::('index.php'); ?>" method="post" class="inline" name="frm">
        <input type="hidden" name="option" value="com_virtuemart"/>


        <input type="text" title="<?php echo  JText::('COM_VIRTUEMART_CART_UPDATE'?>.2" class="inputbox" size="3" maxlength="4" name="quantity" value="<?php echo $prow->quantity ?>" style="display:none;"/>
                <select name="cantidad" id="cantidad" onchange="getval(this);"  value="<?php echo $prow->quantity ?>" title="<?php echo  JText::('COM_VIRTUEMART_CART_UPDATE'?>">   <script type="text/javascript">
                function getval(sel) {
                   document.frm.quantity.value = (sel.value);
                   document.getElementById('actualizar').click();
                }
            </script>
                <option  value="<?php echo $prow->quantity ?>"><?php echo $prow->quantity ?></option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
        </select>           
        <input type="hidden" name="view" value="cart"/>
        <input type="hidden" name="task" value="update"/>
        <input type="hidden" name="cart_virtuemart_product_id" value="<?php echo $prow->cart_item_id  ?>"/>
        <input type="submit" class="vmicon vm2-add_quantity_cart" id="actualizar" name="update" title="<?php echo  JText::('COM_VIRTUEMART_CART_UPDATE'?>" align="middle" value=" " style="display:none;"/>

    </form>


Anyone know how to fix it??
Thank you.

anekro

Here's the code i use and it's working

<form action="<?php echo JRoute::('index.php'); ?>" method="post" class="inline" name="frm<?php echo $j ?>">
<input type="hidden" name="option" value="com_virtuemart"/>

               
<input type="text" title="<?php echo  JText::('COM_VIRTUEMART_CART_UPDATE'?>.2" class="inputbox" size="3" maxlength="4" name="quantity" value="<?php echo $prow->quantity ?>" style="display:none;"/>
            <select name="cantidad" id="cantidad" onchange="getval<?php echo $j ?>(this);"  value="<?php echo $prow->quantity ?>" title="<?php echo  JText::('COM_VIRTUEMART_CART_UPDATE'?>">
                    <option  value="<?php echo $prow->quantity ?>"><?php echo $prow->quantity ?></option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
                <option value="11">11</option>
                <option value="12">12</option>
                <option value="13">13</option>
                <option value="14">14</option>
                <option value="15">15</option>
                <option value="16">16</option>
                <option value="17">17</option>
                <option value="18">18</option>
                <option value="19">19</option>
                <option value="20">20</option>
</select>
<input type="hidden" name="view" value="cart"/>
<input type="hidden" name="task" value="update"/>
<input type="hidden" name="cart_virtuemart_product_id" value="<?php echo $prow->cart_item_id  ?>"/>
<input type="submit" class="vmicon vm2-add_quantity_cart" id="actualizar" name="update" title="<?php echo  JText::('COM_VIRTUEMART_CART_UPDATE'?>" align="middle" value=" " style="display:none;"/>
            <script type="text/javascript">
                    function getval<?php echo $j ?>(sel) {
   document.frm<?php echo $j ?>.quantity.value = (sel.value);
   document.frm<?php echo $j ?>.submit()
                    }
                </script>
</form>