I am trying to get a variable (set on the front end) to be sent through jQuery onClick.
I'm pretty sure it's possible, I just can't figure it out because I'm not familiar with jQuery.
Here is the HTML part:
<input type="text" name="quantity" size="2" value="1" />
<input type="button" value="Add to cart" id="button-cart" class="button" />
And here is my jQuery part:
$('#button-cart').bind('click', function() {
addToCart(
'<?php echo $product_id; ?>',
'$("#quantity").val();'
);
});
But it just doesn't work. I know if I do something like this:
$('#button-cart').bind('click', function() {
addToCart(
'<?php echo $product_id; ?>',
'3'
);
});
That it adds 3 items to the cart but the page needs to be dynamic so the user can enter the quantity needed.
I hope it's clear what I'm trying to do. If anybody could help that would be great. Thank you.