开发者

Calculate order price by date selection value

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

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>

This is the javascript that process the form:

<SCRIPT language=Javascript> 

function PaymentButtonClick() {

    document.addfor开发者_JAVA技巧m.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>


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜