0
我有兩個表單字段,字段1是一個包含不同包裝和價格的選擇菜單,字段2是您想要的數量。現在我找到了一些代碼,它將字段1和字段2的值相加,並將它們相加並最終顯示總和。將兩個字段值相乘
我想改變這個取值來自字段1並將其與來自字段2的值相乘,我該怎麼做?
下面的代碼:( 「sv_313」 是包, 「amountk」 是乘以它的價值)
$(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);
}
+ $ text'如果你想乘兩個變量? – Blender
是的,這正是Venu指出的問題。也謝謝你。 – user1926260