我想写这样的形式这是正确的方法..?

时间:2016-07-20 06:27:09

标签: php



search form
<form action="category.php?type=search" method="post">
select all delete form  
<form name="frmMain" method="post">

</form>
</form>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

如果您使用php发送表单,那么下面是正确的方法:

 //search form
    <form action="category.php?type=search" method="post">

    </form>

//select all delete form  

    <form name="frmMain" method="post">

    </form>

如果你想使用ajax和jquery发送表单,那么你可以使用这种方式:

//search form
<form action="category.php?type=search" method="post">

  //select all delete form  
   <form name="frmMain" method="post">

  </form>
</form>

HTML示例:5个新表单元素(来自answer ilevent):

<form id="saveForm" action="/post/dispatch/save" method="post"></form>
<form id="deleteForm" action="/post/dispatch/delete" method="post"></form>

<div id="toolbar">
 <input type="text" name="foo" form="saveForm" />
 <input type="hidden" value="some_id" form="deleteForm" />
 <input type="text" name="foo2" id="foo2" form="saveForm" value="success" />

    <input type="submit" name="save" value="Save" form="saveForm" onclick="alert(document.getElementById('deleteForm').elements.length + ' ' + document.getElementById('saveForm').elements.length + ' ' + document.getElementById('saveForm').elements['foo2'].value);return false;" />
    <input type="submit" name="delete" value="Delete" form="deleteForm" />
    <a href="/home/index">Cancel</a>
</div>