[英]JavaScript Price calculator script similar to this
Does anybody know a script that is similar to this:有谁知道类似这样的脚本:
http://simplythebest.net/scripts/DHTML_scripts/javascripts/javascript_49.html http://simplythebest.net/scripts/DHTML_scripts/javascripts/javascript_49.html
but only not with input fields, but with options, Yes / No.但不仅不是输入字段,而是选项,是/否。
No but it would be pretty easy to write one... extremely simplified example below:不,但写一个很容易......下面非常简化的例子:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.