`Hi, I am trying to get the option valud from the dropdown and use Javascript to calculate an output. For exmple option 3 is selected I need to show the value of 3 * 13.95 and ge the correct output of 41.85.
html code below.
<div class="">
Red Leicester Cheese
<br>
13,25€ per kilo
<select id="old english" name="oldenglish" onchange="calcVals">
<option value="0" disabled="" selected=""></option>
<option value="1">1 Kilo</option>
<option value="2">2 Kilos</option>
<option value="3">3 Kilos</option>
<option value="4">4 Kilos</option>
<option value="5">5 KiLOS</option>
</select>
<br><label for="weight">Enter Weight</label>
<br>
<input type="number">
</select>
Textbox :
<input name="totalAmount" id="totalAmount" type="text" readonly>
</div>
Javascript below
function calcVals() {
var e = document.getElementById("old english");
var selFrst = e.options[e.selectedIndex].value;
var totalCal = +selFrst * 13.95;
document.getElementById("totalAmount").value = totalCal;
}
I hope someone can help. Thanky you
I tried to get Javascript to calculate a sum and give an output once a value was selected from the drop down but it return no value.