表单提交的几种方法
普通提交:
?
方法一(submit):
?
<form action="url"> //submit 按钮</form>
???
方法二(html):
?
<form action="" name="form1" method="post"> <input type="submit" name="btname" value="提交按钮"onclick="form.action='url';"></form>
?
?
方法三(jQuery):
?
function checksubmit(){ $("#form1").submit(); }
???
方法四(ajax):
?
function checkShooleName(schoolName){var url = "school_get.html?ajax=true";var params = {'schoolName':encodeURI(schoolName),'now':new Date()}var reulst=[];$.ajax({url: url,type: "POST",async:false,data:params,beforeSend: function(XMLHttpRequest){//ShowLoading();},success: function(data, textStatus){reulst = eval(data);},complete: function(XMLHttpRequest, textStatus){//HideLoading();},error: function(){//请求出错处理}});return reulst;}
?
方法五(分支):
function TwoSubmit(form){if (form.Ref[0].checked){form.action = "1url"; //这里是分之一}else{form.action = "2url"; //这里是分之二}form.submit();}
onClick="document.form.submit()"
?
?方法六(javascript):
?
<form name="form1"> <input type="button" name="bt2" onclick="save();"><form>
?
function save(){ document.form1.action="url"; document.forom1.submit();}
?
? 方法七(onsubmit):
?
<form medthod="post" onsubmit="submitTest();"> <input type="submit" value="提交"></form>
?
function submitTest(){ return true; //return fasle; }
?
?
onsubmit="return false;" 阻止表单提交
当onsubmit="submitTest()" 如果返回的是false 那么还是会提交的。
当onsubmit="return saubmitTest()" 如果返回的是false那么不会提交。
??
?
?
?
?