JS自动求和,执行不了 5
如果把文本框放在表单外面就可以,把文本框放在表单里面就算不出来,大侠帮忙看下哪里问题<html><head><metahttp-equiv="content-Type"c...
如果把文本框放在表单外面就可以,把文本框放在表单里面就算不出来,大侠帮忙看下哪里问题
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<SCRIPT language="javascript">
function SumNum()
{
var sumValue
a=eval(aa.value);
b=eval(bb.value);
if (isNaN(a))
{a=0}
if (isNaN(b))
{b=0}
sumValue = a+b;
self['cc'].value =sumValue;
}
</script>
<form name="form1" method="post">
<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="cc" type="text" size="20">
</form>
</body>
</html>
如果把文本框放在表单外面就可以,把文本框放在表单里面就算不出来,大侠帮忙看下哪里问题 展开
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<SCRIPT language="javascript">
function SumNum()
{
var sumValue
a=eval(aa.value);
b=eval(bb.value);
if (isNaN(a))
{a=0}
if (isNaN(b))
{b=0}
sumValue = a+b;
self['cc'].value =sumValue;
}
</script>
<form name="form1" method="post">
<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="cc" type="text" size="20">
</form>
</body>
</html>
如果把文本框放在表单外面就可以,把文本框放在表单里面就算不出来,大侠帮忙看下哪里问题 展开
2个回答
展开全部
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<form id="form1" method="post">
<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="cc" type="text" size="20">
</form>
</body>
<SCRIPT language="javascript">
function SumNum()
{
var sumValue;
var f = document.getElementById("form1");
var aa = f.aa;
var bb = f.bb;
var cc = f.cc;
a=eval(aa.value);
b=eval(bb.value);
if (isNaN(a))
{a=0}
if (isNaN(b))
{b=0}
sumValue = a+b;
//self['cc'].value =sumValue;
cc.value = sumValue;
}
</script>
</html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<form id="form1" method="post">
<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="cc" type="text" size="20">
</form>
</body>
<SCRIPT language="javascript">
function SumNum()
{
var sumValue;
var f = document.getElementById("form1");
var aa = f.aa;
var bb = f.bb;
var cc = f.cc;
a=eval(aa.value);
b=eval(bb.value);
if (isNaN(a))
{a=0}
if (isNaN(b))
{b=0}
sumValue = a+b;
//self['cc'].value =sumValue;
cc.value = sumValue;
}
</script>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询