I have two form fields, field 1 is a select menu with different packages and prices, field 2 is the amount you want. Now I found some code that takes the value from field 1 and field 2 and adds them up and finally shows the sum.
I want to change this to take the value from field 1 and multiply it with the value from field 2, how do I do this ?
Here’s the code: (“sv_313” is the package, “amountk” is the value to multiply it with)
$(function() {
$('#sv_313').on('change', function() {
calculate();
});
$('input[name=amountk]').on('blur', function() {
calculate();
});
});
function calculate() {
var $select = $('#sv_313').val();
var $text = $('input[name=amountk]').val();
if ($select == undefined || $select == '' ||$select == 'Select One') {
$select = 0;
}
else {
$select = parseFloat($select);
}
//
if ($text == undefined || $text == '') {
$text = 0;
}
else {
$text = parseFloat($text);
}
$('.coverage').html($select + $text);
}
You can use