js提交表单方式一:
复制代码 代码示例:
<form action="" name="form1" method="post">
<input type="submit" name="btnSelect" value="追加" class="btn btn-silver"
onClick="form1.action='PersonnelInfoAdd.html';"/>
</form>
js提交表单方式二:
复制代码 代码示例:
<script>
function subMethod(name){
if(name=="b1"){
document.form2.action="a.jsp";
f1.submit();
}
else if(name="b2"){
document.form2.action="b.jsp";
f1.submit();
}
}
</script>
<script>
function save(){
document.form1.action="save.jsp";
document.form1.submit();
}
function send(){
document.form1.action="send.jsp";
document.form1.submit();
}
</script>
<form action="a.jsp" name="form2" method="post">
<input type="button" name="b1" onclick="subMethod('b1');" value="追加">
<input type="button" name="b2" onclick="subMethod('b2');" value="编辑">
</form>
<form name="form1">
<input type="button" name="btn1" value="发送" onclick="send();">
<input type="button" name="btn2" value="保存" onclick="save();">
</form>
做原型的小技巧:
复制代码 代码示例:
<input type="button" name="btnSelect" value="返回" class="btn btn-silver"
Click="history.go(-1)"/>
参考:
js提交form表单的二种方法
js控制form表单提交的实例代码
js回车提交form表单
代码:
复制代码 代码示例:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>回车提交表单</title>
</head>
<body>
<form action="http://www.jb200.com/post.php" method="post" name="myForm">
<input type="text" />
<input type="submit" value="提交" name="tijiao"><font color="#999999">按回车提交表单</font>
</form>
</body>
</html>
<script language="
javascript" type="text/javascript">
document.onkeydown = function(evt){
var evt = window.event?window.event:evt;
if (evt.keyCode==13) {
document.forms["myForm"].submit();
}
}
</script>
推荐:
js自动提交form表单的实例代码