1
JavaScript的價格計算器腳本是否有人知道一個腳本,與此類似:與此類似
http://simplythebest.net/scripts/DHTML_scripts/javascripts/javascript_49.html
,只不過沒有與輸入字段,但與選擇,是/號
JavaScript的價格計算器腳本是否有人知道一個腳本,與此類似:與此類似
http://simplythebest.net/scripts/DHTML_scripts/javascripts/javascript_49.html
,只不過沒有與輸入字段,但與選擇,是/號
無但寫起來會很容易......下面是一個非常簡單的例子:
<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>