Jump to content

create a form within a form by button trigger


I-AM-OBODO

Recommended Posts

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>

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.