Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] error in "JavaScript: The Definitive Guide"?
- From: jdeighan at pcgus.com (John Deighan)
- Subject: [Javascript] error in "JavaScript: The Definitive Guide"?
- Date: Wed Nov 29 07:04:36 2006
I think I've found an error in the JavaScript book I use the most. Before reporting it to O'Reilly, though, I thought I'd pass it by some of the JavaScript gurus on this list. The book says: 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. I checked both IE and FF, and, in fact, I've programmed functions that split a query string and this is the way it was always done. Also, I think this is the correct way, though it does lead to problems if you try to put the values of CGI variables into a hash, because a hash can have only one entry for each key. You might say that in that case, you could put the values into a list, but there's no way to know if the original form had multiple checkboxes, but the user only checked one, so that would still give programmers headaches since they would expect a list, but not get one. Anyway, I digress... I guess what I'm not positive about is whether the data is actually sent in the first form, but the CGI subsystem converts it to the second form before passing it to my Perl script. At first I thought that that could not be the case since I'm able to distinguish whether two checkboxes with the values '1' and '2' were checked, from the case where a single checkbox with the value '1,2' was checked. However, when I tried it I realized that a comma in a checkbox's value would be escaped, so it's possible that the first case is sent as: name=1,2 and the second is sent as: name=1%2C2 so they could be distinguished. So, does anyone know what's really going on here? P.S. I guess I could figure this out myself if I knew how to use a packet sniffer like Ethereal. I have it, but never found the time to figure it out.
- Follow-Ups:
- [Javascript] error in "JavaScript: The Definitive Guide"?
- From: Nick Fitzsimons
- [Javascript] error in "JavaScript: The Definitive Guide"?
- From: diego nunes
- [Javascript] error in "JavaScript: The Definitive Guide"?
- From: Nick Fitzsimons
- [Javascript] error in "JavaScript: The Definitive Guide"?
- References:
- [Javascript] dynamically hide an element
- From: Dong, Roland
- [Javascript] dynamically hide an element
- From: Mark Kelly
- [Javascript] dynamically hide an element
- From: Flávio Gomes
- [Javascript] dynamically hide an element
- From: Nick Fitzsimons
- [Javascript] dynamically hide an element
- Prev by Date: [Javascript] dynamically hide an element
- Next by Date: [Javascript] error in "JavaScript: The Definitive Guide"?
- Previous by thread: [Javascript] dynamically hide an element
- Next by thread: [Javascript] error in "JavaScript: The Definitive Guide"?
- Index(es):