gpt4 book ai didi

javascript - 根据日期选择值计算订单价格

转载 作者:行者123 更新时间:2023-11-28 10:33:25 26 4
gpt4 key购买 nike

好吧,我知道有一个简单的方法可以做到这一点,但我已经很多年没有做过很多 JavaScript 了

我的客户有一个用于事件注册的在线订单(由以前的网络开发人员开发)。目前订单总额只是一个隐藏字段:

<INPUT value=78.00 type=hidden name=amount />

但我需要根据他们选择的日期来计算总数:

<SELECT style="BACKGROUND-COLOR: #ffff99" name=altDate1>
<OPTION value=04/09> Friday, April 9 </OPTION>
<OPTION value=04/14> Wednesday, April 14 </OPTION>
<OPTION value=04/16> Friday, April 16 </OPTION>
<OPTION value=04/19> Monday, April 19 </OPTION>
<OPTION value=04/29> Thursday, April 29 </OPTION>
</SELECT>

这是处理表单的 javascript:

<SCRIPT language=Javascript> 

function PaymentButtonClick() {

document.addform.Product_Name.value = document.Information.StudentLastName.value + ","+
document.Information.StudentFirstName.value+","+
document.Information.StudentID.value+","+
document.Information.altDate1.name+","+","+
document.Information.Guests.value+ "," +
document.Information.StudentType.value;

document.addform.Product_Code.value = document.Information.StudentID.value;


if ((document.Information.UCheck.checked==true) &&
(document.Information.altDate1.value != "") &&
(document.Information.altDate1.value != "x")) {

if (document.Information.StudentLastName.value != "" ||
document.Information.StudentFirstName.value != "" ||
document.Information.StudentID.value != "" ) {

document.addform.submit();
}
else {
alert("Please enter missing information");
}
}
}

</SCRIPT>

最佳答案

将此 switch 语句插入您的表单处理函数中:

switch (document.Information.altDate1.value) {
case '04/09':
document.Information.amount.value = 78.00;
break;
case '04/14':
document.Information.amount.value = 79.00;
break;
case '04/16':
document.Information.amount.value = 80.00;
break;
case '04/19':
document.Information.amount.value = 81.00;
break;
case '04/29':
document.Information.amount.value = 82.00;
break;
}

关于javascript - 根据日期选择值计算订单价格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2359238/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com