HighDots Forums  

forms that look like grids -- are values correlated?

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss forms that look like grids -- are values correlated? in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris Curvey
 
Posts: n/a

Default forms that look like grids -- are values correlated? - 06-05-2008 , 02:13 PM






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?)

Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: forms that look like grids -- are values correlated? - 06-05-2008 , 02:51 PM






Scripsit Chris Curvey:

Quote:
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.

Quote:
now if I submit that form the resulting URL looks like

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

Quote:
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.

Quote:
(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/inte...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/



Reply With Quote
  #3  
Old   
Adrienne Boswell
 
Posts: n/a

Default Re: forms that look like grids -- are values correlated? - 06-06-2008 , 01:56 AM



Gazing into my crystal ball I observed "Jukka K. Korpela"
<jkorpela (AT) cs (DOT) tut.fi> writing in news:LAW1k.13008$_03.9042
@reader1.news.saunalahti.fi:

Quote:
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/inte...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.

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

Then I parse the array and manipulate it as needed. The OP will need to
look at the server language's documentation to see how to manipulate the
data.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share



Reply With Quote
  #4  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: forms that look like grids -- are values correlated? - 06-06-2008 , 09:18 AM



Scripsit Adrienne Boswell:

Quote:
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/



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.