Shaddy Baddah wrote:
>
> I am puzzled by the use of form controls outside of form blocks? Is it
> allowed? I have every reason to trust the strict DTD, and according to it,
> %formctrl entity is an item of the %inline entity. This means that an
> element of the %formctrl entity, say the INPUT element, can form the content
> of a number of elements other than FORM, say a P (paragraph element).
I recently reviewed a website hat had its form input outside of the
form.
<form name="frm1" method="post" onSubmit="callservlet("/foobar"); return
false;">
<input type="hidden" name="foo">
</form>
<input name="bar">
<form name="frm2" method="post" onSubmit="callservlet("/foobar"); return
false;">
<input type="text" name="foo">
</form>
<a href="#" onClick="callservlet("/foobar"); return false;">
<img src="ok.gif" bordr=0>
</a>
Alot is wrong with this code, not only did they have some of the form
inputs
outside the form, but they also use Javasript to script standadr HTML
behaviour
in a non standard way.
What the callservlet function does is to copy the value of "foo" in
"frm2" to
the hidden "foo" of "frm1", check the values of "fo" and "bar" of
"frm1",
and then submit "frm1" to the given URL. Their code actually is able
access
"bar" its value by accessing "frm1" This is strange since technically
the "bar"
input has no relation other to "frm1" than that it is defined after
"frm1"
Current browsers (tested with IE5, IE6, Mozilla 1.2) seem to remember
the last
declared form and assign it as the parent of any following stray input.
It is a bit strange that the HTML4.01 DOM allows an form input to be of
inline. (I haven't check upon this.) The only reason for this (as far as
I can come up with currently) is that it is intended to be used for some
UI
purpose. Say declae an checkbox somewhere in a document that is not
intended
to be posted but only to be used as user input for a script.
Christian