HTML Help
How do I add create a multi line POST form?
A solution when presenting a form to customers with multiple rows of options and you want each row to act as a form.
You might have tried using multiple forms, one for each row of the table. Unfortunately you can't nest forms within table elements. If you only required the user to confirm the contents of a row without changing the data, you could avoid using forms by using GET as follows:
Using GET:
| Item | Price | Quantity | |
| Thimbles | £25.00 | 5 | |
| Gumbits | £25.00 | 3 | |
Each button looks like this with the item id and quantity coded into the URL:
<a href="accept_order.php?item=101&quantity=5">
<img src="images/order.gif" alt="order" border="0" />
</a>
However if you need to allow the user to update the quantity, you have to use a single form. We'll use javascript to update a single hidden quantity value:
Using POST:
A single form surrounds the table
We're using a form with a single hidden field to keep track of the quantity. Default is 0
The buttons are no longer images, but are submit buttons which we use to identify the item id and submit the form:
<input type="image" src="images/order.gif" name="Submit" value="101">
When we change the quantity field, a javascript line changes the quantity hidden field:
<input name="quantity101" type="text" id="quantity101" size="3" maxlength="3" onblur="document.form1.quantity.value=document.form1.quantity101.value;" />
You'll probably want to embed all of this into PHP, Perl or whatever else you want in order to auto generate the item id's so that each row has a unique quantity name and order submit value.
Keywords: HTML, GET, POST, fom, multiline, multi line, submit, rows, multiple forms

