I have a select box with product models
<select name="name" id="name">
<option value=" ">Seleccione cantidad</option>
<?php
$eliminar = $product['model'];
$terms = substr($eliminar, 0, 9);
$modelo_query = $this->db->query("SELECT * FROM product WHERE model LIKE '%" . $terms . "%'");
$modelos = array();
if ($modelo_query->num_rows > 0) {
foreach ($modelo_query->rows as $result) {
$modelos[] = array('modelo' => $result['model'],);
?>
<option value="<?php echo $result['model']; ?>"><?php echo $result['model']; ?></option>
<?php } } ?>
</select>
When I select a option i need to change this $product['product_id']:
onclick="addQtyToCart('<?php echo $product['product_id']; ?>');"
and this:
id="quantity-<?php echo $product['product_id']; ?>"
in this code:
<input type="text" name="quantity" value="" class="input-mini" id="quantity-<?php echo $product['product_id']; ?>"/>
<input type="button" value="<?php echo $button_cart; ?>" onclick="addQtyToCart('<?php echo $product['product_id']; ?>');" class="btn btn-cart btn-small" />
The function addQtyToCart:
<script type="text/javascript">
function addQtyToCart(product_id) {
var qty = document.getElementById("quantity-" + product_id).value;
addToCart(product_id, qty);
document.getElementById("quantity-" + product_id).value = "";
}
</script>