表单提交,处理值

retrying 2004-08-14 12:41:08
<form name="form1" method="post" action="">
<input name="a1" type="text" onchange="checkValue()">
<input name="a2" type="text" onchange="checkValue()">
<input name="a3" type="text">
</form1>

<script >

function checkValue()
{
if (document.form1.a1.value>=4 || document.form1.a2.value>=4 )
document.form1.a3.value=4;
return;
else
document.form1.a3.value =0;
}

</script>


我想要的功能是,如果A1大于4 或是A2大于4 则A3等于4。
再有,我再处理前首先要处理一下是不是数值
...全文
87 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fashchina 2004-08-14
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body><form name="form1" method="post" action="">
<input name="a1" type="text" onchange="checkValue()" onKeyPress="event.returnValue=IsDigit();">
<input name="a2" type="text" onchange="checkValue()" onKeyPress="event.returnValue=IsDigit();">
<input name="a3" type="text">
</form1>

<script >

function checkValue()
{ if(document.form1.a1.value>=4 || document.form1.a2.value>=4 )
{document.form1.a3.value=4;
return true;}
else
{document.form1.a3.value =0;}
}

</script>
</body>
</html>
<script language="javascript">
<!--
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
-->
</script>
retrying 2004-08-14
  • 打赏
  • 举报
回复
谢谢,成功,结贴
woyingjie 2004-08-14
  • 打赏
  • 举报
回复
<form name="form1" method="post" action="">
<input name="a1" type="text" onchange="checkValue()">
<input name="a2" type="text" onchange="checkValue()">
<input name="a3" type="text">
</form1>

<script >

function checkValue()
{
if (parseInt(document.form1.a1.value)>=4 || parseInt(document.form1.a2.value)>=4 ){
document.form1.a3.value="4";
return;
}
else{
document.form1.a3.value ="0";
}
}

</script>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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