on dropdown change i would like to put the price on the textbox "price" base on the selected value in dropdown
function Price(data) {
document.getElementById ("productprice").value = data.value;
}
<select name="product" onchange="Price(this)">
<option value="" disabled="disabled" selected="selected">Please select a product</option>
<?php
foreach ($product as $product) {
?>
<option value="<?php echo $product['Product']?>" id="<?php echo $product['Price']?>"><?php echo $product['Product'] . " Qty: " . $product['Quantity']?></option>
<?php
}
?>
</select>
<input id="productprice" type="text" name="price" />
i did get try to multi value but how do i only get the 2nd value to appear in textbox
<select name="product" onchange="Price(this)">
<option value="" disabled="disabled" selected="selected">Please select a product</option>
<?php
foreach ($product as $product) {
?>
<option value="<?php echo $product['Product']?>,<?php echo $product['Price']?>"><?php echo $product['Product'] . " Qty: " . $product['Quantity']?></option>
<?php
}
?>
</select>