您的位置:首页 > 水果行情水果行情
javascript 显示两种水果的价格 javascript
admin2024-07-15人已围观
<script>
function T(){
var price = document.getElementById(price).options[document.getElementById(price).selectedIndex].value;
var num = document.getElementById(num).value;
if(num){
var total = price * num;
document.getElementById('total').innerHTML = total+元;
}
}
</script>
<br />
<form>
水果:<select id=price>
<option value=2>西瓜(2元/斤)</option>
<option value=5>苹果(5元/斤)</option>
<option value=7.5>榴莲(7.5元/斤)</option>
</select><br /><br />
数量:<input type='text' id=num value=1 size=4 /><br /><br />
总价:<span id=total style=color:red;></span><br /><br />
<input type=button value=计算 onclick=T() /> <input type=reset value=清空 onclick=document.getElementById('total').innerHTML=''; />
</form>
很赞哦! ()
上一篇:广州水果批发市场进货渠道有哪些'>谈谈自媒体、新媒体和融媒体
下一篇:返回列表'>返回列表