Click here to get back home

forms that look like grids -- are values correlated?

 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
forms that look like grids -- are values correlated? Chris Curvey 06-05-2008
Posted by Chris Curvey on June 5, 2008, 2:13 pm
Please log in for more thread options
I have a form like this, which looks like a grid of entries.

<form method="get" action="/dosomething>
<table>
<tr>
<td><input type="text" name="foo" value="1"></td>
<td><input type="text" name="bar" value="3"></td>
</tr>

<tr>
<td><input type="text" name="foo" value="2"></td>
<td><input type="text" name="bar" value="4"></td>
</tr>
</table>
</form>

now if I submit that form the resulting URL looks like

/dosomething?foo=1&bar=3&foo=2&bar=4

so, my question is: are the values guaranteed to be correlated? that
is, can I assume that the the first entries for foo & bar (1&3) go
"together" and the second entries (2&4) "go together"?

(or perhaps a better questions is, "What are the rules (if any) for
multiple fields with the same name, and do they vary by browser?)

Posted by Jukka K. Korpela on June 5, 2008, 2:51 pm
Please log in for more thread options
Scripsit Chris Curvey:

> I have a form like this, which looks like a grid of entries.

Why? It looks contrived, and it has poor accessibility, since input
fields have no labels and there is no easy way (and maybe no feasible
way) add them.

> now if I submit that form the resulting URL looks like
>
> /dosomething?foo=1&bar=3&foo=2&bar=4

OK.

> so, my question is: are the values guaranteed to be correlated?

By the specifications, yes. In practice, there should be no reason to
count on it. Good form data processing starts from parsing the data into
variables, normally losing the order anyway.

> (or perhaps a better questions is, "What are the rules (if any) for
> multiple fields with the same name, and do they vary by browser?)

For multiple fields with the same name, data from all of them is
included if they are "successful" at the time of submission. See
http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.2
The successful of a text field is subject to interpretation if no data
has been typed into it, but browsers seem to treat them as successful
with empty values, including data like
foo=
into the form data set. Anyway, the important thing is that if two
fields with the same name have been filled out, both are "successful",
hence included, but don't count on any particular order. A very cautious
man might avoid using the same name, at least if there is an easy
alternative.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Posted by Jukka K. Korpela on June 6, 2008, 9:18 am
Please log in for more thread options
Scripsit Adrienne Boswell:

> What I get on the server is an array containing the values,eg:
> foo = a, b, c, d

Perhaps, but that's external to both HTML and HTTP. It is a matter of
the server-side interface between incoming HTTP data and your scripting
environment.

You might have a problem there with some forms and some data, so you may
need to check, from suitable documentation, how the interface handles
a) fields with empty values, such as
foo=
(does it generate an element in the array, just with empty content?)
b) identical fields, e.g.
foo=a
foo=a
(does it generate two elements or just one element the array? The latter
would mean loosing some information, though this might be quite
acceptable and even desirable - it really depends)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Similar ThreadsPosted
sending hidden values AND option values at the same time ? September 12, 2006, 12:52 am
[Repost] Sudoku grids September 15, 2005, 11:07 am
make style on grids of table January 26, 2005, 5:32 pm
Forms - howto use return for submitting in Forms? April 6, 2005, 4:08 pm
Smallest Possible width values April 1, 2005, 6:02 am
Class attribute values November 7, 2005, 7:27 am
splitting long attribute values February 16, 2007, 10:05 pm
how pass option values to JS routine? November 18, 2007, 10:16 am
Form Reload with Tainted Values April 28, 2008, 5:13 pm
receipt of form values by an HTML page October 10, 2007, 2:56 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap