Click here to get back home

What happens if several text fields have the same name?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
What happens if several text fields have the same name? wolfing1 05-24-2005
Get Chitika Premium
Posted by wolfing1 on May 24, 2005, 10:00 am
Please log in for more thread options


Like, I know if several checkboxes have the same name, I can get the
ones that were checked after submit with a request.form("name") and
maybe do a split(request.form("name"),",") to cycle through them.
I tried the same thing with textfields (input type=text), but doesn't
seem to work the same.
Do they behave differently?


Posted by Jim Moe on May 24, 2005, 12:45 pm
Please log in for more thread options


wolfing1@yahoo.com wrote:
> Like, I know if several checkboxes have the same name, I can get the
> ones that were checked after submit with a request.form("name") and
> maybe do a split(request.form("name"),",") to cycle through them.
> I tried the same thing with textfields (input type=text), but doesn't
> seem to work the same.
>
My experience is that you get the contents of the text box that is last
defined with a given name. None of the others show up.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

Posted by Alan J. Flavell on May 24, 2005, 10:10 pm
Please log in for more thread options


On Tue, 24 May 2005, Jim Moe wrote:

> My experience is that you get the contents of the text box that is last
> defined with a given name. None of the others show up.

Then you have an incomplete server-side implementation, but this
is off-topic for the HTML authoring group.

The HTML spec specifies the format of the submitted dataset (as sent
from the client to the server). That part is on-topic here.

The interface between the server and your server-side process depends
a bit on what it is (CGI, ASP, PHP, whatever), but the most portable
interface is defined by the CGI, which is now an informational RFC
http://www.ietf.org/rfc/rfc3875 , and would be on-topic in
comp.infosystems.www.authoring.cgi (beware the automoderation bot).

Any complete implementation should give you access to multiple values
from "form control(s)"[1] with the same name.

At this point in the procedure the server neither knows nor cares what
kind of form control that was. They could easily be of different
kinds (e.g a pull-down list and a type-in text box of the same name)
if you wanted. Or not, as you choose.

have fun

[1] using that term as it's used in the html4 spec.


Posted by RobG on May 25, 2005, 6:40 am
Please log in for more thread options


Alan J. Flavell wrote:
> On Tue, 24 May 2005, Jim Moe wrote:
>
>
>> My experience is that you get the contents of the text box that is last
>>defined with a given name. None of the others show up.
>
>
> Then you have an incomplete server-side implementation, but this
> is off-topic for the HTML authoring group.

I disagree with that. If the OP is serving invalid HTML that has INPUT
text elements with duplicate names, browser behaviour is not defined
and you can't be certain of what will be returned to the server.

In that context, it is very much a HTML issue.

>
> The HTML spec specifies the format of the submitted dataset (as sent
> from the client to the server). That part is on-topic here.

And what the server sends to the client is irrelevant? The server needs
to start out by sending valid HTML (or whatever is specified in the
DOCTYPE), otherwise you are just guessing at what the UA may do.

[...]
> At this point in the procedure the server neither knows nor cares what
> kind of form control that was. They could easily be of different
> kinds (e.g a pull-down list and a type-in text box of the same name)
> if you wanted. Or not, as you choose.

If that was to occur in the same form, then that is invalid HTML and UA
behaviour may not be what you expect.

> have fun
>
> [1] using that term as it's used in the html4 spec.


--
Rob

Posted by Alan J. Flavell on May 25, 2005, 12:42 pm
Please log in for more thread options


On Wed, 25 May 2005, RobG wrote:

> Alan J. Flavell wrote:
> > On Tue, 24 May 2005, Jim Moe wrote:
> >
> > > My experience is that you get the contents of the text box that is last
> > > defined with a given name. None of the others show up.
> >
> > Then you have an incomplete server-side implementation, but this is
> > off-topic for the HTML authoring group.
>
> I disagree with that. If the OP is serving invalid HTML

I still see no evidence that the OP needs to serve "invalid" HTML to
achieve this.

> text elements with duplicate names, browser behaviour is not defined
> and you can't be certain of what will be returned to the server.

The behaviour is defined in
http://www.w3.org/TR/html4/interact/forms.html#form-data-set

If two "successful controls" have the same name, then the "form data
set" submitted to the server will contain two name=value pairs with
the same name.

That is a specification of the form data set as submitted from the
browser/client to the server. It's not a specification of a software
interface between a server and a server-side process - you'd need to
look elsewhere for that, as I already said.

> > The HTML spec specifies the format of the submitted dataset (as
> > sent from the client to the server). That part is on-topic here.
>
> And what the server sends to the client is irrelevant?

Congratulations, you're arguing against something that I never said.

> > At this point in the procedure the server neither knows nor cares
> > what kind of form control that was. They could easily be of
> > different kinds (e.g a pull-down list and a type-in text box of
> > the same name) if you wanted. Or not, as you choose.
>
> If that was to occur in the same form, then that is invalid HTML

Where's your test document to demonstrate this claimed invalidity?


Similar ThreadsPosted
text fields in a form February 11, 2007, 2:33 pm
Is there a way to change the color of the text fields in html? March 9, 2006, 11:51 am
non-remembering fields November 8, 2007, 1:29 pm
form fields and no-cache July 22, 2004, 11:10 pm
Hidden name= fields question June 18, 2005, 12:59 pm
HTML Form "Lookup" Fields May 8, 2005, 4:23 am
HTML entities from input fields January 11, 2006, 9:25 am
How do you line up separate fields in a select box? May 3, 2006, 10:12 am
Moving to 4.01 strict: problem with hidden fields et al. January 16, 2005, 9:00 pm
Upper limit on number of fields? May 5, 2005, 11:25 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap