按日期选择值计算订单价格 [英] Calculate order price by date selection value

查看:90
本文介绍了按日期选择值计算订单价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我知道有一种简单的方法可以做到这一点,但是距离我已经完成了很多javascript已有多年了

Alright, I know there's a simple way to do this, but it's been years since I've done much javascript

我的客户有一个用于事件注册的在线订购表(由以前的Web开发人员开发).目前,订单总数只是一个隐藏字段:

My client has an online order form for event registration (developed by previous web dev.). Currently the order total is just a hidden field:

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

但是我需要根据他们选择的日期进行总计:

But I need the total to calculate based on what date they choose:

<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:

This is the javascript that process the form:

<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语句插入表单处理函数:

Insert this switch statement into your form processing function:

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;
}

这篇关于按日期选择值计算订单价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆