求救-关于不同按钮提交不同的页面!

sos_hawk 2003-03-27 11:27:45
代码:
<form name=form1 method="post">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type="submit" name=sub1>
<input type="submit" name=sub2>
</form>
请问,如果按提交按钮‘sub1’提交到1.asp;按提交按钮‘sub2’提交到2.asp
相应值也传过去。该如何实现?
...全文
27 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
fason 2003-03-27
  • 打赏
  • 举报
回复
for(i=0;i<f.chk.length;i++)if(f.chk[i].checked)alert("the "+i+1+" is selected")
fason 2003-03-27
  • 打赏
  • 举报
回复
改成这样
<script>
function check(f){
if(!f.chk[0].checked){alert(1);return false}
return true
}
</script>
<form name=form1 method="post" onsubmit="return check(this)">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type="submit" value=1 name=sub1 onclick="this.form.action='1.asp';">
<input type="submit" value=2 name=sub2 onclick="this.form.action='2.asp';">
</form>
  • 打赏
  • 举报
回复
<form name=form1 method="post">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type="button" value=1 name=sub1 onclick="this.form.action='1.asp';this.form.submit()">
<input type="button" value=2 name=sub2 onclick="this.form.action='2.asp';this.form.submit()">
</form>
sos_hawk 2003-03-27
  • 打赏
  • 举报
回复
怎样判断一组checkbox中某几个选中?
sos_hawk 2003-03-27
  • 打赏
  • 举报
回复
fason(阿信) 兄:
提交之前还需数据的检查,该怎么做?谢谢!
tenflee 2003-03-27
  • 打赏
  • 举报
回复
同意楼上的fason(阿信),这样方法确实有效,俺也经常用 :)
sinzy 2003-03-27
  • 打赏
  • 举报
回复
<input type="button" name="sub1" onClick="GoTo(1)">
<input type="button" name="sub3" onClick="GoTo(2)">

..

function GoTo(where)
{
switch(where)
{
case 1:
form1.action = "1.asp";
form1.submit();
break;
case 2:
form1.action = "2.asp";
form1.submit();
break;
.....
// 依此类推
fason 2003-03-27
  • 打赏
  • 举报
回复
<form name=form1 method="post">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type="button" value=1 name=sub1 onclick="this.form.action='1.asp';this.form.submit()">
<input type="button" value=2 name=sub2 onclick="this.form.action='2.asp';this.form.submit()">
</form>
fason 2003-03-27
  • 打赏
  • 举报
回复
<form name=form1 method="post">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type=checkbox name="chk">
<input type="button" value=1 name=sub1 onclick="this.form.action='1.asp';this.form.submit()">
<input type="button" value=2 name=sub2 onclick="this.form.action='1.asp';this.form.submit()">
</form>

28,391

社区成员

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

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