如何从两个选定的下拉列表中计算值并显示在文本框中?
而且我想计算汽车不买点击按钮..
HTML代码保险:
<select class="form-control" name="insurance" onchange="calcVals()" id="insurance">
<option disabled="" selected="" ></option>
<option value="200">Yes</option>
<option value="0">No </option>
</select>
人手:
<select class="form-control" name="manpower" id="manpower" onchange="calcVals()">
<option disabled="" selected=""></option>
<option value="150">1</option>
<option value="300">2</option>
<option value="450">3</option>
<option value="600">4</option>
<option value="750">5</option>
</select>
文本框 :
<input name="totalAmount" id="totalAmount" type="text" readonly>
javascript:
function calcVals() {
var e = document.getElementById("manpower");
var selFrst = e.options[e.selectedIndex].text;
var f = document.getElementById("insurance");
var selScnd = f.options[f.selectedIndex].text;
var totalCal = selFrst + selScnd;
document.getElementById("totalAmount").value = totalCal;
}
慕丝7291255
慕妹3242003
明月笑刀无情
相关分类