Forum Moderators: open

Message Too Old, No Replies

Form split across two DIVs

It's not valid, so looking for alternatives

         

Purple Martin

1:12 am on Aug 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I'm building one of those forms which shows a couple of simple fields and has an "Advanced options..." link that will display more fields.

My first attempt was structured like this:

<FORM>
<DIV>
...simple fields...
</DIV>
<DIV>
...more fields...
</DIV>
</FORM>


The second DIV was hidden until the user clicked on the "Advanced options..." link. It worked beautifully.

But then I validated the document and got told that DIVs aren't allowed inside forms. I can't use SPANs either because fields aren't allowed inside them. I don't want to use two forms (one in each DIV), because it would give me submit headaches.

Is there a way I can have one form split across two DIVs (or SPANs or whatever) and keep my document valid?

Thanks in advance!

mbauser2

1:16 am on Aug 8, 2002 (gmt 0)

10+ Year Member



The FIELDSET element [w3.org] is intended for dividing up forms. Try that.

bird

1:40 am on Aug 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I hope you're writing your tags in lowercase in reality, or you'll have to eventually change them all (XHTML is all lowercase).

To your problem: You need to specify your form as display:inline explicitly, as it is a block element by default:

<form style="display:inline;">
<div>
...

As long as the form is a block element, it behaves pretty much like a paragraph (or div), which can't be seperated either.

Purple Martin

2:02 am on Aug 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mbauser2, the fieldset element is exactly what I'm looking for, thanks!

bird, I can see the logic of using the form as an inline element instead of a block element, but the HomeSite validator still doesn't like it.

Mind you, I'm not sure I trust the HomeSite validator: it says that the input tag isn't allowed within fieldset, and I just don't believe that :o