2013-08-27 60 views
2

任何想法如何處理這個問題?我的問題是,當我在form2上提交form1自動提交。我想要的是當我在form2上提交時,只有form2提交它。請檢查此示例代碼。Codeigniter在form_open上提交form1 form2

<?php echo form_open('form1'); ?> 

<input type="text" name="name"> 


       <?php echo form_open('form2'); ?> 
        <input type="text" name="note"> 
         <input type="submit" value="button2"> // this form2 is to insert note on this day 
       <?php echo form_close(); ?> 

       // then under this form2 we have a table. Table for list of note that all ready insert.   


<input type="submit" value="button1"> // this form1 is to save all. the "Name" and also the note that we insert it on form2    
<?php echo form_close(); ?> 
+0

你爲什麼把form2放在form1裏面? – Yalamber

+0

,因爲在form2下我有一張桌子。並且該表格正在form1下保存。這就是爲什麼我需要兩種形式。這個問題有可能先生? – wewe

+0

表格2正在表格下保存。 – wewe

回答

1

我不認爲這是嵌套形式編程的好方法。但是在對你的問題進行一些研究之後發現了這個可以幫助你的問題的鏈接。 Click here

希望能爲你工作。一切順利!

+0

謝謝你的這個鏈接:) – wewe

+0

M很高興它爲you.just投票了答案在回報 – Dash

+0

我有一個問題,但不是一個大問題先生。 – wewe

0

您的嵌套提交元素更改爲

<input type="submit" name="form2_button" value="form2_submit"/> 

然後,您可以檢查使用

if(isset($_POST["form2_button"]))` or in codeigniter you can input->post('form2_button') 

具有的另一種形式的嵌套形式是內部表單提交不是一個有效的HTML/XHTML。但是你可以嘗試上面的代碼。