I have a form with a dropdown select menu of products and a text field that should contain the price of the product. The dropdown menu is dynamically populated from a mysql database via php. I need for the text field to automatically be filled with the price associated with that product (in the same row in the database) once the product is selected from the dropdown list.
What I have so far is:
<label>Product or Service</label>
<select name="product" required>
<option value=""></option>
<?php $productSql = "SELECT product_id, product, price FROM products ORDER BY product desc";
$productResult = mysql_query($productSql, $link);
while($productRow = mysql_fetch_assoc($productResult)){?>
<option value="<?php echo $productRow['product_id'];?>"><?php echo $productRow['product']; ?></option><?php } ?>
</select>
<label>Price</label>
<input type="text" name="price">