合计的代码怎么写?有人能帮修改正确吗?

nnwind 2016-01-30 06:18:57
最后合计的代码怎么写?有人能帮修改正确吗?
代码运行后如下图:


请在源代码中修改,谢谢。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<title></title>
</head>
<body>
<p>请在黄色框内输入数字,将自动计算合计。</p>
<table width="800" border="1" cellspacing="2" cellpadding="9">
<tr>
<th width="40" bgcolor="#CCCCCC" scope="col">次数</th>
<th width="40" bgcolor="#CCCCCC" scope="col">扣分</th>
<th width="40" bgcolor="#CCCCCC" scope="col">评分小计</th>
</tr>
</table>
<SCRIPT language="javascript">
function SumNum1()
{
var sumValue1
a=eval(_1.value);
b=0.1
if (isNaN(a))
{a=0}
sumValue1 = a*b;
self['_2'].value =sumValue1;
var sumValue2
a=eval(_1.value);
b=0.1
if (isNaN(a))
{a=0}
sumValue2 = 5-a*b;
self['_3'].value =sumValue2;
}

</script>

<table width="800" border="1" cellspacing="2" cellpadding="10">
<tr>
<th width="40" bgcolor="#FFFF00" scope="col"><input id="_1" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum1();"></th>
<th width="40" scope="col"><input id="_2" type="text" size="5"></th>
<th width="40" scope="col"><input id="_3" type="text" size="5"></th>
</tr>
</table>

<SCRIPT language="javascript">
function SumNum2()
{
var sumValue3
c=eval(_4.value);
d=0.5
if (isNaN(c))
{c=0}
sumValue3 = c*d;
self['_5'].value =sumValue3;
var sumValue4
c=eval(_4.value);
d=0.5
if (isNaN(c))
{c=0}
sumValue4 = 5-c*d;
self['_6'].value =sumValue4;
}

</script>

<table width="800" border="1" cellspacing="2" cellpadding="10">
<tr>
<th width="40" bgcolor="#FFFF00" scope="col"><input id="_4" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum2();"></th>
<th width="40" scope="col"><input id="_5" type="text" size="5"></th>
<th width="40" scope="col"><input id="_6" type="text" size="5"></th>
</tr>
</table>

<SCRIPT language="javascript">
function SumNum3()
{
var sumValue13
a3=eval(_13.value);
b3=0.2
if (isNaN(a3))
{a3=0}
sumValue13 = a3*b3;
self['_23'].value =sumValue13;
var sumValue23
a3=eval(_13.value);
b3=0.2
if (isNaN(a3))
{a3=0}
sumValue23 = 5-a3*b3;
self['_33'].value =sumValue23;
}

</script>

<table width="800" border="1" cellspacing="2" cellpadding="10">
<tr>
<th width="40" bgcolor="#FFFF00" scope="col"><input id="_13" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum3();"></th>
<th width="40" scope="col"><input id="_23" type="text" size="5"></th>
<th width="40" scope="col"><input id="_33" type="text" size="5"></th>
</tr>
</table>

<script type="text/javascript">
function add(){
// 如果不是数字,或者没有填写就默认为0
var var111 = parseFloat(document.getElementById(self['_3']).value) || 0;
var var222 = parseFloat(document.getElementById(self['_6']).value) || 0;
var var333 = parseFloat(document.getElementById(self['_33']).value) || 0;

document.getElementById('_39').value = var111 + var222 + var333;
}
</script>
<table width="800" border="1" cellspacing="2" cellpadding="10">
<tr>
<th width="30" scope="col">合计</th>
<th width="40" scope="col"><input id="_39" type="text" size="5"></th>
</tr>
</table>
</body>
</html>
...全文
214 3 打赏 收藏 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
nnwind 2016-02-17
  • 打赏
  • 举报
回复
非常感谢!已给分结帖。
slwsss 2016-02-16
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-Type" content="text/html;charset=gb2312"> <title></title> </head> <body> <p>请在黄色框内输入数字,将自动计算合计。</p> <table width="800" border="1" cellspacing="2" cellpadding="9"> <tr> <th width="40" bgcolor="#CCCCCC" scope="col">次数</th> <th width="40" bgcolor="#CCCCCC" scope="col">扣分</th> <th width="40" bgcolor="#CCCCCC" scope="col">评分小计</th> </tr> </table> <SCRIPT language="javascript"> function SumNum1() { var sumValue1 a=eval(_1.value); b=0.1 if (isNaN(a)) {a=0} sumValue1 = a*b; self['_2'].value =sumValue1; var sumValue2 a=eval(_1.value); b=0.1 if (isNaN(a)) {a=0} sumValue2 = 5-a*b; self['_3'].value =sumValue2;add() } </script> <table width="800" border="1" cellspacing="2" cellpadding="10"> <tr> <th width="40" bgcolor="#FFFF00" scope="col"><input id="_1" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum1();"></th> <th width="40" scope="col"><input id="_2" type="text" size="5"></th> <th width="40" scope="col"><input id="_3" type="text" size="5"></th> </tr> </table> <SCRIPT language="javascript"> function SumNum2() { var sumValue3 c=eval(_4.value); d=0.5 if (isNaN(c)) {c=0} sumValue3 = c*d; self['_5'].value =sumValue3; var sumValue4 c=eval(_4.value); d=0.5 if (isNaN(c)) {c=0} sumValue4 = 5-c*d; self['_6'].value =sumValue4;add() } </script> <table width="800" border="1" cellspacing="2" cellpadding="10"> <tr> <th width="40" bgcolor="#FFFF00" scope="col"><input id="_4" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum2();"></th> <th width="40" scope="col"><input id="_5" type="text" size="5"></th> <th width="40" scope="col"><input id="_6" type="text" size="5"></th> </tr> </table> <SCRIPT language="javascript"> function SumNum3() { var sumValue13 a3=eval(_13.value); b3=0.2 if (isNaN(a3)) {a3=0} sumValue13 = a3*b3; self['_23'].value =sumValue13; var sumValue23 a3=eval(_13.value); b3=0.2 if (isNaN(a3)) {a3=0} sumValue23 = 5-a3*b3; self['_33'].value =sumValue23;add() } </script> <table width="800" border="1" cellspacing="2" cellpadding="10"> <tr> <th width="40" bgcolor="#FFFF00" scope="col"><input id="_13" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum3();"></th> <th width="40" scope="col"><input id="_23" type="text" size="5"></th> <th width="40" scope="col"><input id="_33" type="text" size="5"></th> </tr> </table> <script type="text/javascript"> function add(){ // 如果不是数字,或者没有填写就默认为0 var var111 = parseFloat(document.getElementById('_3').value) || 0; var var222 = parseFloat(document.getElementById('_6').value) || 0; var var333 = parseFloat(document.getElementById('_33').value) || 0; document.getElementById('_39').value = var111 + var222 + var333; } </script> <table width="800" border="1" cellspacing="2" cellpadding="10"> <tr> <th width="30" scope="col">合计</th> <th width="40" scope="col"><input id="_39" type="text" size="5"></th> </tr> </table> </body> </html>
nnwind 2016-02-16
  • 打赏
  • 举报
回复
顶一下,请大家帮忙,谢谢。

87,984

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧