1个回答
展开全部
<html>
<head>
<script>
function cal() {
var appleVolum = Number(document.getElementById("appleVolum").value);
var bananaVolum = Number(document.getElementById("bananaVolum").value);
var pineappleVolum = Number(document.getElementById("pineappleVolum").value);
document.getElementById("msg").value = "共花费:" + (appleVolum * 10 + bananaVolum * 20 + pineappleVolum * 20);
}
</script>
</head>
<body>
苹果每斤10元,请输入您要购买的斤数:<input id="appleVolum"><br>
香蕉每斤20元,请输入您要购买的斤数:<input id="bananaVolum"><br>
菠萝每斤20元,请输入您要购买的斤数:<input id="pineappleVolum"><button onclick="cal()">我买</button><br>
信息:<input id="msg">
</body>
</html>
<head>
<script>
function cal() {
var appleVolum = Number(document.getElementById("appleVolum").value);
var bananaVolum = Number(document.getElementById("bananaVolum").value);
var pineappleVolum = Number(document.getElementById("pineappleVolum").value);
document.getElementById("msg").value = "共花费:" + (appleVolum * 10 + bananaVolum * 20 + pineappleVolum * 20);
}
</script>
</head>
<body>
苹果每斤10元,请输入您要购买的斤数:<input id="appleVolum"><br>
香蕉每斤20元,请输入您要购买的斤数:<input id="bananaVolum"><br>
菠萝每斤20元,请输入您要购买的斤数:<input id="pineappleVolum"><button onclick="cal()">我买</button><br>
信息:<input id="msg">
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询