标签:register sub b2c log ref 幽默 sdn rip img
form表单提交的几种方法
<form id="myform" name="myform" method="post" onsubmit="return sumbitTest();"
action="RegisterAction.action">
<table>
<tr>
<td>姓名:</td>
<td> <input type="text" name="name" /> </td>
</tr>
<tr>
<td>性别:</td>
<td>
<input type="radio" name="sex" value="1"> 男
<input type="radio" name="sex" value="0"> 女
</td>
</tr>
<tr>
<td>年龄:</td>
<td>
<select name="age">
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit普通提交">
<input type="button" id="ajaxBtn" value="AJAX提交" />
<input type="button" id="jqueryBtn" value="jQuery提交" />
<input type="button" id="jsBtn" value="JS提交" />
<input type="submit" value="onSubmit提交" />
</td>
</tr>
</table>
</form>
<script type="text/javascript">
$(function() {
//ajax提交
$("#ajaxBtn").click(function() {
var params = $("#myform").serialize();
$.ajax( {
type : "POST",
url : "RegisterAction.action",
data : params,
success : function(msg) {
alert("success: " + msg);
}
});
})
//jQuery提交
$("#jqueryBtn").click(function(){
$("#myform").submit();
})
//js提交
$("#jsBtn").click(function(){
document.myform.action="RegisterAction.action";
document.myform.submit();
})
})
function sumbitTest(){
return true; //return false则不会提交
}
</script>
以上是比较常用的几种表单提交方式,但绝不局限于这些
作者:itmyhome
出处:http://blog.csdn.net/itmyhome1990/article/details/41849175
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net
标签:register sub b2c log ref 幽默 sdn rip img
原文地址:https://www.cnblogs.com/skiwnchqhh/p/10138662.html