我需要理论上的澄清...... JavaScript 表单提交和包含提交按钮的表单有什么区别?
(我正在使用框架Struts,但我认为它不会影响行为。)
我的意思是,这是我的例子,提交表单和提交表单有什么区别input type="submit"
?
<html:form action="search.do?method=mySearch" method="post" styleId="searchFilterForm">
<input type="hidden" name="myfield" value="">
<table border="0" class="filterclass" width="530px">
<tr>
<td class="filterheader" align="center">
<input type="submit" onclick="doMySubmit()" name="MyList" value="SEND" class="button actionbutton" />
</td>
</tr>
</table>
</html:form>
function doMySubmit() {
var myform = document.getElementById('searchFilterForm');
myform.myfield.value = "Hello World";
}
并在 JavaScript 中使用 submit 提交表单?
<html:form action="search.do?method=mySearch" method="post" styleId="searchFilterForm">
<table border="0" class="filterclass" width="530px">
<tr>
<td class="filterheader" align="center">
<input type="button" onclick="doMySubmit()" name="MyList" value="SEND" class="button actionbutton" />
</td>
</tr>
</table>
</html:form>
function doMySubmit() {
var myform = document.getElementById('searchFilterForm');
myform.myfield.value = "Hello World";
myform.submit();
}