本章节介绍一下如何根据不同的情况使表单跳转到不同的页面,下面就通过一个例子做一下简单介绍。

代码实例如下:
   [ 其他 ] 运行代码    下载代码
<!DOCTYPE html>   
<html>   
<head>   
<meta charset=" utf-8">   
<meta name="author" content="https://www.51qianduan.com/" />   
<title>51前端</title>
<style type="text/css"> 
body{ 
  margin:0; 
  padding:0; 
} 
ul li{
  list-style:none;
}
</style> 
<script type="text/javascript">  
window.onload=function(){
  var antzone=document.getElementById("antzone");
  var qq=document.getElementById("qq");
  var theform=document.theform;
  antzone.onclick=function(){
    theform.action="http://www.softwhy.com";
    theform.submit();
  }
  qq.onclick=function(){
    theform.action="http://www.qq.com";
    theform.submit();
  }
}
</script> 
</head> 
<body> 
<form action="#" name="theform"/>
<ul>
  <li>姓名:<input type="text" value="51前端"/></li>
  <li>密码:<input type="password" value="123456"/></li>
  <li>
    <input type="button" id="antzone" value="51前端"/>
    <input type="button" id="qq" value="腾讯集团"/>
  </li>
</ul>
</form>
</body> 
</html>

代码描述:JavaScript让form表单 根据不同条件 提交不同页面。JavaScript让form表单根据不同条件提交到不同页面源码下载



130 173



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册



×
×
51前端

注册

×
绑定手机

请绑定手机号,在继续操作

×
单次下载支付

应付金额:279

支付完成后,回到下载页面,在进行下载

官方QQ群
意见反馈
qq群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到