I-AM-OBODO Posted April 21, 2012 Share Posted April 21, 2012 Hi, how can i create a form within a form with the click of a button? so that when i click add new item, it brings form fields under the current one. hope my explanation helps thanks <form id="form1" name="form1" method="post" action=""> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="22%">Invoice Number </td> <td width="78%"> </td> </tr> <tr> <td>Date Issued </td> <td> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="10%">Quantity</td> <td width="70%">Description</td> <td width="9%">Taxable</td> <td width="11%">Amnount</td> </tr> <tr> <td valign="top"><input name="textfield" type="text" size="7" /></td> <td valign="top"><textarea name="textfield2" cols="80"></textarea></td> <td valign="top"><input type="checkbox" name="checkbox" value="checkbox" /></td> <td valign="top"><input name="textfield3" type="text" size="12" /></td> </tr> <tr> <td colspan="4"><input type="submit" name="Submit" value="Add New Item" /></td> </tr> </table></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/261359-create-a-form-within-a-form-by-button-trigger/ Share on other sites More sharing options...
Drummin Posted April 21, 2012 Share Posted April 21, 2012 You can't have a form within a form. You can change lines within a form, for example input fields or submit as new or as an update, but nesting forms is not allowed. Quote Link to comment https://forums.phpfreaks.com/topic/261359-create-a-form-within-a-form-by-button-trigger/#findComment-1339272 Share on other sites More sharing options...
I-AM-OBODO Posted April 21, 2012 Author Share Posted April 21, 2012 You can't have a form within a form. You can change lines within a form, for example input fields or submit as new or as an update, but nesting forms is not allowed. but i have seen something of that sort. i am trying to model from what i saw in bamboo invoice an application built with codeigniter. whatever he used, i dont know but all i know is that when you click add button, it brings out another form field Quote Link to comment https://forums.phpfreaks.com/topic/261359-create-a-form-within-a-form-by-button-trigger/#findComment-1339274 Share on other sites More sharing options...
Drummin Posted April 21, 2012 Share Posted April 21, 2012 Sure, just add another submit button named to do this task. <input type="submit" name="add_field" value="Add Field" /> Then within your form you add something like this. if (isset($_POST['add_field'])){ echo '<input type="text" name="mynewfield" />'; } You'll want to "name" your submit field and processing script accordingly so it's not triggered when the "Add Field" button is clicked. Quote Link to comment https://forums.phpfreaks.com/topic/261359-create-a-form-within-a-form-by-button-trigger/#findComment-1339277 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.