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

diego nunes dnunes at gmail.com
Wed Nov 29 08:14:47 CST 2006


On 11/29/06, John Deighan <jdeighan at pcgus.com> 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

    As far as I know, in ASP you have the "bla=1,2,3,4" format, but it
doesn't happen with all languages. I just don't get the point of why
this happens, 'cause, in theory, it's the browser that handle this,
but, anyway, try this:
<form action="teste.asp">
  <input type="text" name="teste" value="mimimi" />
  <input type="text" name="teste" value="blabla" />
</form>

    When in ASP, it appear as "teste=mimimi,blabla", but in PHP it
will be "teste=mimimi&teste=blabla", which gives you only one value
when getting the querystring ($_GET['teste'] returns only "blabla").
In PHP I always use name="DESIRED_NAME[]" (note the "[]" at the end),
which gives you an Array with the values, in the server side language
-- obviously it doens't work with ASP at all.

--
diego nunes
dnunes.com



More information about the Javascript mailing list