Hello Everyone!
I’ve got a little javascript issue maybe someone could give me a hand with. Might be easy for you, not for me.
Here’s what I have…
A selector:
<select name="cart[<?php echo $_item->getId() ?>][qty]" onchange="form.submit()" style="padding:0">
<?php for($i = $min_sale_qty; $i <= $total_qyt; $i = $i + $min_sale_qty) : ?>
<option value="<?php echo $i?>" <?php echo ($i == $this->getQty())? "selected=selected": ""; ?>>
<?php echo $i?>
</option>
<?php endfor;?>
</select>
and a input:
<input name="cart[<?php echo $_item->getId() ?>][qty]"
data-cart-item-id="<?php echo $this->jsQuoteEscape($_item->getSku()) ?>"
value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />
I got a new module that has some javascript to target the input field but I’ve change the input to the selector a long time ago.
Here’s the javascript:
<script>
document.observe( 'dom:loaded', function(){
/* ADD ACTION COLUMN */
$$('#shopping-cart-table tbody tr input.qty').each( function( qty_input ){
item_id = $(qty_input).readAttribute('name').replace( /(^.+\D)(\d+)(\D.+$)/i,'$2'); // Thank you Stack Overflow (http://stackoverflow.com/questions/609574/get-the-first-ints-in-a-string-with-javascript)
//$(':last-child', qty_input.up().up ).insert( '<strong>Test</strong>' );
qty_input.up().up().select("td:last-child")[0].insert('<br /><br /><a href="<?php echo Mage::getUrl('saveforlater'); ?>index/save/item/'+ item_id +'" class="saveforlater-action">Save for Later</a>');
} );
/* END ADD ACTION COLUMN */
} );
</script>
I would like to target the selector instead of the input field. How could I do that?
Thank you