[Javascript] error in "JavaScript: The Definitive Guide"?

Nick Fitzsimons nick at nickfitz.co.uk
Wed Nov 29 09:15:36 CST 2006


On 29 Nov 2006, at 13:04:18, John Deighan wrote:

> For input elements of type "radio" and "checkbox", it is common to  
> define more than one related object, each of which have the same  
> 'name' property. In this case, data is submitted to the server with  
> this format:
>
> 	name=value1,value2,...,valuen
>
> I've checked with a simple HTML page that submits to a Perl script,  
> and the query string that the script receives has duplicate entries  
> with the same name, like this:
>
> 	name=1&name=2&name=3
>
> including only those values where the checkbox was actually checked.

One other thing that's potentially confusing about the sentence you  
quote ("For input elements...") is that when a form contains multiple  
radio buttons with the same name, they form a group in which only one  
of them can be selected, and therefore only one name-value pair will  
be submitted for that radio button group. So radio groups are, in  
fact, irrelevant to the information being presented.

Also, one can have inputs of other types (e.g. multiple text input  
fields) with the same name, so the suggestion that this is limited to  
checkboxes is also a possible source of confusion.

(Of course, nothing stops you giving the same name to a radio group,  
a bunch of checkboxes, some text fields, and the submit button. That  
would be fun to parse ;-)

Regards,

Nick.

-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/






More information about the Javascript mailing list