[thelist] Form ids vs names
David Dorward
evolt at david.us-lot.org
Fri Apr 16 09:46:06 CDT 2004
On 16 Apr 2004, at 15:15, Alex Robinson wrote:
> I found some previous posts from 2000 that bemoaned the fact that
> browsers were not yet sending the values of input fields that had an
> id rather than a name - as per the HTML 4 and up specs.
Where in the HTML 4 and up specification does it say that the value of
the is attribute should be used when submitting forms?
A control's "control name" is given by its name attribute.
The scope of the name attribute for a control within a FORM
element is the FORM element.
When a form is submitted for processing, some controls have
their name paired with their current value and these pairs
are submitted with the form.
http://www.w3.org/TR/html4/interact/forms.html#control-name
The method attribute of the FORM element specifies the HTTP
method used to send the form to the processing agent. This
attribute may take two values:
* get: With the HTTP "get" method, the form data set is
appended to the URI specified by the action attribute
(with a question-mark ("?") as separator) and this new
URI is sent to the processing agent.
* post: With the HTTP "post" method, the form data set is included
in the body of the form and sent to the processing agent.
http://www.w3.org/TR/html4/interact/forms.html#submit-format
A form data set is a sequence of control-name/current-value
pairs constructed from successful controls
http://www.w3.org/TR/html4/interact/forms.html#form-data-set
Which we can compare to:
id = name [CS]
This attribute assigns a name to an element. This name
must be unique in a document.
http://www.w3.org/TR/html4/struct/global.html#adef-id
Nowhere does it mention that the id attribute should be used when a
form is submitted, and if it was then it would make such things as
radio button groups rather difficult to implement.
> From my rough and ready testing it seems that none of the modern
> browsers (Firefox, Safari 1.2 and Opera 7.5) have yet bothered to do
> so either.
They are correctly following the spec
> What gives? Have the browser developers just forgotten this or has
> there been a decision to just ignore the specs? Or am I just confused
> and have gotten hold of the wrong end of the stick?
Stick. Pointy end. Ouch.
> In any case, is the best solution to send identical values for both
> name and id attributes for now?
It makes is easier to track things in some cases, but you can't give
the same id value to, for instance:
<fieldset>
<legend>What rodent do you like?</legend>
<input type="radio" id="animalrat" name="animal" value="Rat">
<label for="animalrat">Rat</label> <br>
<input type="radio" id="animalmouse" name="animal" value="Mouse">
<label for="animalmouse">Mouse</label>
</fieldset>
--
David Dorward
<http://dorward.me.uk/>
<http://blog.dorward.me.uk/>
More information about the thelist
mailing list