当我在一个页面中有多个表单时,如何在单击“提交”按钮后获取对特定表单的控件

时间:2022-09-26 10:09:52

after reloading the page, the control should be on a particular form. i tried but its not working please help me guys..

重新加载页面后,控件应该在特定的表单上。我试过但它不工作请帮助我们..

form{width:100px; height:200px;}
<html>
<body>
   <form name="1"><input type="button" name="submit" value="SAVE">      </form>
   <form name="2"><input type="button" name="submit" value="SAVE">      </form>
   <form name="3"><input type="button" name="submit" value="SAVE">      </form>
   <form name="4"><input type="button" name="submit" value="SAVE">      </form>
   <form name="5"><input type="button" name="submit" value="SAVE">      </form>
</body>
</html>

like this i am having forms, if i click on submit button of form 3, then it should save the content and reload and it should take me back to the form 3.

像这样我有表格,如果我点击表格3的提交按钮,那么它应该保存内容并重新加载,它应该带我回到表格3。

2 个解决方案

#1


3  

 <form name="1" id="one">
   <input type="hidden" name="form_id" value="one" />
  <input type="button" name="one" value="SAVE1">      
 </form>

 header('Location:page_name.php#'.$_POST['form_id']);

#2


1  

Add id="one" in each form and set the form id into value of hidden input field like this .

在每个表单中添加id =“one”,并将表单id设置为隐藏输入字段的值,如下所示。

 <form name="1" id="one">
   <input type="hidden" name="form_id" value="one" />
  <input type="button" name="one" value="SAVE1">      
 </form>

PHP :

PHP:

//do your all stuff here 
// finally add last submitted form id like this  

 header('Location:page_name.php#'.$_POST['form_id']);

#1


3  

 <form name="1" id="one">
   <input type="hidden" name="form_id" value="one" />
  <input type="button" name="one" value="SAVE1">      
 </form>

 header('Location:page_name.php#'.$_POST['form_id']);

#2


1  

Add id="one" in each form and set the form id into value of hidden input field like this .

在每个表单中添加id =“one”,并将表单id设置为隐藏输入字段的值,如下所示。

 <form name="1" id="one">
   <input type="hidden" name="form_id" value="one" />
  <input type="button" name="one" value="SAVE1">      
 </form>

PHP :

PHP:

//do your all stuff here 
// finally add last submitted form id like this  

 header('Location:page_name.php#'.$_POST['form_id']);