I have a select menu with various option values. I need to multiply the selected value by "10" if the value selected is less than 25, if the value selected is 25 or greater I need it to multiply by "12".
I am new to JS. I am able to get it to work by multiplying by just 10 using the code below, but I do not know how to write the if/else statement to check if the selection is less than 25 and multiply by 10 or 25 or greater and multiply by 12.
Html:
<table width="100%" border="0">
<tr>
<td>
<select id="licenseRegs">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="75">75</option>
<option value="100">100</option>
<option value="125">125</option>
</select>
</td>
<td id="total-price">Price show here</td>
</tr>
</table>
Javascript: This multiplies all select values by 10. I need it to multiply by 10 if less than 25 but multiply by 12 if 25 or more.
// calculate price of # of computer selection
$(document).ready(function() {
var pricePerReg = 10;
var licenseRegsSelect = $('#licenseRegs');
function updateTotalPrice() {
licenseRegs = licenseRegsSelect.val();
$('#price').html(pricePerReg * licenseRegs);
}
licenseRegsSelect.change(function() {
updateTotalPrice();
});
updateTotalPrice();
});