Forum Moderators: open

Message Too Old, No Replies

Form tags inside cells of tables

Do I have to use <form></form> in every cell?

         

LABachlr

9:15 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



I am making a page with a form on it where clients will submit information for a custom quote. I am using <select></select> tags for most of the values on the form, and <textarea></textarea> tags with some of the values. Each value will be in its own cell in a large table.

I was wondering if I have to use the <form name="name" method="method" action="action"></form> tag inside each cell, or just at the beginning of the page where I start inserting the form tags, and at the bottom of the page after the last form tag?

There will be other parts of the page in between the <select></select> values where it is strictly HTML, and is not part of the form.

If I do use the <form> tag at the beginning and end of each value, do I use the same <form name="">?

Reflection

10:34 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



You only need one set of <form></form> tags on the page, but all of your form tags(select etc.) must be between <form> and </form>.

So before your first form tag start your <form> and then after the last form tag close the </form>.

LABachlr

2:51 am on Sep 24, 2003 (gmt 0)

10+ Year Member



OK. Thanks. I assume that you mean at the top of the form, there is only one form tag that has the following attributes:

<form name="name" method="method" action="action">

which is at the top of the page, or at least before the first form tag.

And all of the form tags have just the following:

<form><formtag>form tag elements</formtag></form>

And then you have the closing </form> after the last tag.

And by the way, how does the reset button work? I have inserted it with the following code, but it does not work:

<form><input type="reset" name="Clear Form"></form>

What's missing?

defanjos

2:58 am on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Very simple example of one that works:

<form name="form1" method="post" action="whatever">
<input type="text" name="textfield1">
<br>
<input type="text" name="textfield2">
<br>
<input type="text" name="textfield3">
<br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</form>

LABachlr

3:15 am on Sep 24, 2003 (gmt 0)

10+ Year Member



Yeah, that works fine. It is because I have a open and close <form> tag at the beginning and end of each form element (<select></select>)?

Should I just have one opening form tag at the top of the page:

<form name="name" method="method" action="action">

and one closing one

</form>

at the bottom of the page, and none after each form element (<select></select>), even though there are elements in the page that are not form related?

<edit>Scratch that thought...doesn't work...you need the <form> tag before and after each element in the form</edit>

[edited by: LABachlr at 3:31 am (utc) on Sep. 24, 2003]

LABachlr

3:17 am on Sep 24, 2003 (gmt 0)

10+ Year Member



Or does the reset button not work for the <select> tag? I would think that it would.

jetboy_70

11:29 am on Sep 24, 2003 (gmt 0)

10+ Year Member



Dude, you're scaring people ...

As the two previous posters have said; you only use one set of <FORM></FORM> tags. You DO NOT wrap each individual element with <FORM></FORM> tags.

As for the reset button. It will work with <SELECT>s, but I'd imagine you'd have to specify a default setting such as:

<OPTION VALUE="myvalue" SELECTED="SELECTED">

LABachlr

3:11 am on Sep 25, 2003 (gmt 0)

10+ Year Member



I hate to tell you guys, but that is not correct. I have tried coding it the way you guys suggested by just having <form name="name" method="method" action="action"> at the beginning of the form, and </form> at the end of the form and the form elements in between. But like I said, there are many non-form HTML elements within the form between the form elements as well. This, somehow, is precluding the above coding format to work.

Here is how the page is setup. It it one big table with 244 rows and 5 columns. Columns 1 and 5 are empty. Columns 2 and 3 contain plain text (Col. 2 is the quantity of the item, and Col. 3 is the description of the item). Column 4 is the column that has all of the <select></select> tags so that the visitor can chose how many of each item they would like included in their submission.

I removed all of the form tags that were wrapped around each individual form element. No problems there. However, placing the <form></form> tags is what's creating the problem.

When I place the <form name="name" method="method" action="action"> tag right above the first <select> tag for the first form element in the same cell as the element, it acts as if there is no close form tag(</form>), and the form tag coding actually appears on the page. This happens even though there is a close form tag (</form>) after the last form element in the form at the bottom of the form. My guess is that it is because the close form tag is in a different cell then the open form tag.

I have even tried placing the <form> tags in empty cells at the top and bottom of the page, but it's still a no go. I also tried placing the open form tag above and outside of the large table, and the close form tag below and outside of the large table, but that does not work either.

Any thoughts on this one?

Yes, defanjos's example does work. But that is because none of the elements are in different cells in a table.

wkitty42

3:32 am on Sep 25, 2003 (gmt 0)

10+ Year Member



ummm... don't put the <form> </form> tags in the table cells...

<form name="form1" method="post" action="whatever"> 
<table>
<tr>
<td><input type="text" name="textfield1"></td>
<td><input type="text" name="textfield2"></td>
<td><input type="text" name="textfield3"></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</form>

that's how i recall doing it way back when...

LABachlr

6:26 am on Sep 25, 2003 (gmt 0)

10+ Year Member



ummm... don't put the <form> </form> tags in the table cells...

Very cool. Thanks. The page has more tables than just the main one, so I tried putting the <form> tag right after the <div> tag at the top of the page, and the </form> tag right before the </div> tag at the bottom of the page, and everything is good to go! Even the reset button works!

Thanks!

that's how i recall doing it way back when...

LOL. Way back when? What do you use now? CSS? PHP?