找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 366|回复: 2

[求助]很急的问题

[复制链接]
发表于 2010-1-15 08:10:38 | 显示全部楼层 |阅读模式 IP:江苏扬州
<script language="javascript">
function BtnOK_Click()
{
var Sum=0;
var n1,n2,n3,n4,n5;
n1=eval(document.form1.aa.value);
n2=eval(document.form1.bb.value);
n4=eval(document.form1.sum1.value);
n3=n1+n2+n4;
document.form1.sum2.value=n3
for(var i=0;i<10;i++)
{
if(form1.selField[i].checked)
Sum+=parseInt(form1.selField[i].value);
document.form1.sum1.value=Sum
}
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>表单1:
<input name="aa" type="text" id="aa" value="50" size="10">
表单2:
<input name="bb" type="text" id="bb" value="50" size="10"></td>
</tr>
<tr>
<td>
<input type="checkbox" name="selField" value="50">a1
<input type="checkbox" name="selField" value="50">a2
<input type="checkbox" name="selField" value="50">a3
<input type="checkbox" name="selField" value="50">a4
<input type="checkbox" name="selField" value="50">
a5 =
<input name="sum1" type="text" size="10"></td>
</tr>
<tr>
<td>总数:

<input name="sum2" type="text" size="20"></td>
</tr>
<tr>
<td><input type="button" name=BtnOK value="确定" onClick="BtnOK_Click();" ></td>
</tr>
</table>
</form></td>
</tr>
</table>
现在得问题是:为什么要“确定”两次才能算出总数。再者:A1,A2,A3,A4,A5,这几个只是用来测试得,它们或者只有1个,或者一个都没有,当没有的时候肯定不能相加了,或者有十个,最多只有10个,当没时候只能是表单1和表单2相加了,如果有的话,它是可选项,这个选择是由客户自己决定的,可选,可不选,可多选。怎样解决这个问题呢?
发表于 2010-1-15 08:10:42 | 显示全部楼层 IP:江苏扬州
<script language="javascript">
function BtnOK_Click()
{
var Sum=0;
var n1,n2,n3,n4,n5;
n1=eval(document.form1.aa.value);
n2=eval(document.form1.bb.value);
for(var i=0;i<5;i++)
{
if(form1.selField[i].checked)
Sum+=parseInt(form1.selField[i].value);
document.form1.sum1.value=Sum
}
n4=eval(document.form1.sum1.value);
n3=n1+n2+n4;
document.form1.sum2.value=n3
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>表单1:
<input name="aa" type="text" id="aa" value="50" size="10">
表单2:
<input name="bb" type="text" id="bb" value="50" size="10"></td>
</tr>
<tr>
<td>
<input type="checkbox" name="selField" value="50">a1
<input type="checkbox" name="selField" value="50">a2
<input type="checkbox" name="selField" value="50">a3
<input type="checkbox" name="selField" value="50">a4
<input type="checkbox" name="selField" value="50">
a5 =
<input name="sum1" type="text" size="10"></td>
</tr>
<tr>
<td>总数:

<input name="sum2" type="text" size="20"></td>
</tr>
<tr>
<td><input type="button" name=BtnOK value="确定" onClick="BtnOK_Click();" ></td>
</tr>
</table>
</form></td>
</tr>
</table>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 11:32 , Processed in 0.236853 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表