我有一個標準的計算javascript,現在我需要插入基於用戶選擇的值的多個計算 - 似乎無法讓它工作....!任何機會有人可以看看,並告訴我我要去哪裏錯了?Javascript:從下拉列表中選擇值
<script type="text/javascript">
function calculate() {
var noPeople = document.ContactForm.noPeople.value;
var ddl = document.getElementById("menuType");
var selectedValue = ddl.options[ddl.selectedIndex].value;
var noPeople_excess = (noPeople-6);
if (selectedValue == 3) {
var basic = 337;
var marchCost = (50*noPeople);
if (marchCost <= basic) {
document.ContactForm.marchCost.value = 337;
document.ContactForm.marchCostVin.value = basic +(noPeople*25)
} else {
document.ContactForm.marchCost.value = basic +(noPeople_excess*34);
document.ContactForm.marchCostVin.value = basic +(noPeople_excess*34)+(noPeople*25)
}
} else (selectedValue == 4) {
var basic = 368;
var marchCost = (55*noPeople);
if (marchCost <= basic) {
document.ContactForm.marchCost.value = 368;
document.ContactForm.marchCostVin.value = basic +(noPeople*25)
} else {
document.ContactForm.marchCost.value = basic +(noPeople_excess*44);
document.ContactForm.marchCostVin.value = basic +(noPeople_excess*44)+(noPeople*25)
}
} else (selectedValue == 5) {
var basic = 419;
var marchCost = (60*noPeople);
if (marchCost <= basic) {
document.ContactForm.marchCost.value = 419;
document.ContactForm.marchCostVin.value = basic +(noPeople*25)
} else {
document.ContactForm.marchCost.value = basic +(noPeople_excess*54);
document.ContactForm.marchCostVin.value = basic +(noPeople_excess*54)+(noPeople*25)
}
}
}
</script>
你能詳細說明究竟是什麼錯誤嗎? – Aashray
您是否期待我們調試這整個事情?只隔離有問題的部分併發布它 – Itay
基本上,當沒有下拉菜單時,計算工作和成本在表單上給出。現在有多個值可供選擇,沒有任何反應,表單上沒有任何內容出現。 – user2818741