<html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>11</title> </head> <body> <SCRIPT language="javascript"> function SumNum() { var sumValue c=eval(cc.value); a=eval(aa.value); b=eval(bb.value); if (isNaN(a)) {a=0} if (isNaN(b)) {b=0} if (isNaN(c)) {b=0} sumValue = a+b+c; self['zong'].value =sumValue; } </script> <select id="cc"> <option value="60" "SumNum();">值是60</option> <option value="0" "SumNum();">值是0</option> </select> <input id="aa" type="text" size="20" onkeyup="value=value.replace(/[^d.]/g,'');SumNum();"> <input id="bb" type="text" size="20" onkeyup="value=value.replace(/[^d.]/g,'');SumNum();"> <input id="zong" type="text" size="20"> </body> </html> <SCRIPT language="javascript"> function SumNum() { var sumValue c =parseInt( document.getElementById('cc').value) a = parseInt( document.getElementById('aa').value) b = parseInt(document.getElementById('bb').value) if (isNaN(a)) { a = 0 } if (isNaN(b)) { b = 0 } if (isNaN(c)) { b = 0 } sumValue = a + b + c; document.getElementById('zong').value = sumValue; } </script> <select id="cc" onchange="SumNum()"> <option value="60">值是60</option> <option value="0">值是0</option> </select> <input id="aa" type="text" size="20" onkeyup="value=value.replace(/[^d.]/g,'');SumNum();"> <input id="bb" type="text" size="20" onkeyup="value=value.replace(/[^d.]/g,'');SumNum();"> <input id="zong" type="text" size="20">
<html> <head> <title>11</title> </head> <body> <SCRIPT language="javascript"> function SumNum() { var sumValue; var c = parseFloat(document.getElementById("cc").value)||0; var b = parseFloat(document.getElementById("bb").value)||0; var a = parseFloat(document.getElementById("aa").value)||0; sumValue = a+b+c; document.getElementById("zong").value =sumValue; } </script> <select id="cc" onchange="SumNum();"> <option value="60">值是60</option> <option value="0">值是0</option> </select> <input id="aa" type="text" size="20" onkeyup="value=value.replace(/[^d.]/g,'');SumNum();"> <input id="bb" type="text" size="20" onkeyup="value=value.replace(/[^d.]/g,'');SumNum();"> <input id="zong" type="text" size="20"> </body> </html>
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索parsefloat
, document
, value
, var
, getelementbyid
, cc++11c++c++基础
isnan
js计算精度问题、js自动计算价格、js input 自动计算、js 自动计算总金额、js输入框自动计算,以便于您获取更多的相关知识。
时间: 2025-01-21 02:07:31