HTML计算商品总价

HTML计算商品总价,第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>

给你说下思路, document.getElementById("top").rows.length可以获得top表的行数 document.getElementById("top").rows[0].cells.length可以获得top表的第一行的列数 document.getElementById("top").rows[0].cells[0].offsetWidth可获得top表第一行第一列的实际宽度,(注意,这个是只读的!)所以 for(var i=0i


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7601277.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-07
下一篇 2023-04-07

发表评论

登录后才能评论

评论列表(0条)

保存