JavaScript计算 - 基于某些区域

时间:2013-12-11 12:18:48

标签: javascript jquery sum

我正在尝试根据国家/地区内的某些区域创建简单的交付计算价格。

例如,这是用于计算区域价格的表格:

enter image description here

因此,如果用户选择英国区域3及其前往法国区域4.价格将为68英镑

我正在努力学习如何进行计算。我有一个JS小提琴显示下拉列表,但不知道如何进行计算。

$("#from").change(function() {
            // foo is the id of the other select box 
            if ($(this).val() == "United Kingdom") {
                $(".uk-zones").show();
            }else{
                $(".uk-zones").hide();
            }

            if ($(this).val() == "Germany") {
                $(".de-zones").show();
            }else{
                $(".de-zones").hide();
            } 

            if ($(this).val() == "France") {
                $(".fr-zones").show();
            }else{
                $(".fr-zones").hide();
            }
        });

        $("#to").change(function() {
            // foo is the id of the other select box 
            if ($(this).val() == "United Kingdom") {
                $(".uk-zones2").show();
            }else{
                $(".uk-zones2").hide();
            } 

            if ($(this).val() == "Germany") {
                $(".de-zones2").show();
            }else{
                $(".de-zones2").hide();
            } 

            if ($(this).val() == "France") {
                $(".fr-zones2").show();
            }else{
                $(".fr-zones2").hide();
            } 

        });

http://jsfiddle.net/barrycorrigan/vzq8w/

我的javascript不是最好的。但任何帮助解决这个问题都会有很大的帮助。

0 个答案:

没有答案