I have a select where I complete the options with the data of the products that I have stored in my bbdd. The code is as follows:
<select name="p1" id="select1" required />
<option selected="true" disabled="disabled">Elige un producto</option>
<?php
foreach($productos as $prod)
{
echo "<option value=".$prod['id'].">".$prod['nombre']." (".$prod['precio']." €)</option>";
}
?>
</select>
What I need is to store the value of $ prod ['price'] of the selected option, to then perform an arithmetic operation and display it elsewhere in the page dynamically.
On some previous occasion I used the onChange event to launch a function js and show the selected value but I do not know if it is possible mixing it with php. Also in this case the "value" corresponds to another data that I must save in the bbdd What would be the appropriate option?