JavaScript价格计算器脚本与此类似

时间:2010-04-25 22:17:36

标签: javascript options

是否有人知道与此类似的脚本:

http://simplythebest.net/scripts/DHTML_scripts/javascripts/javascript_49.html

但不是输入字段,而是选项,是/否。

1 个答案:

答案 0 :(得分:0)

不,但编写一个非常简单......下面的简化示例:

<script type="text/javascript">
var product1price = 85;
var product2price = 23;
function CalculatePrice()
{
    var totalprice = 0;
    if (document.getElementById('product1select').value == "yes")
    {
        totalprice += product1price;
    }
    if (document.getElementById('product2select').value == "yes")
    {
        totalprice += product2price;
    }
    document.getElementById('pricesum').innerHTML = totalprice;
}
</script>
<select id="product1select"><option value="yes">Yes</option><option value="">No</option></select>
<br><select id="product2select"><option value="yes">Yes</option><option value="">No</option></select>
<br>Total Price: <span id="pricesum">0</span>
<br><button onclick="CalculatePrice()">Get Price</button>