On Wed, May 20, 2009 at 6:50 AM, Ford, Mike <m.f...@leedsmet.ac.uk> wrote:
> On 19 May 2009 17:10, Andrew Ballard advised:
>>               var toppings = document.sundae.toppings;
>>                 // To work with PHP, the above line would
>> have to be changed:
>>                 // var toppings =
>> document.sundae.elements['toppings[]'];
> Actually, document.sundae['toppings[]'] is sufficient (because it is
> defined in JavaScript that a['b'] is always exactly equivalent to a.b).
> Cheers!
> Mike

True enough. I suppose it makes sense to just use the JavaScript array
notation syntax for accessing form elements all the time and not worry
about it any more.

I'll admit that when I first learned PHP3, it even seemed cool that
you could add elements to arrays (even nested or multi-dimensional
arrays) automatically by placing the appropriate square brackets in
the field name. At the time, having the language automatically create
variables for each of my form fields compared with what I had to do in
PERL seemed pretty cool too. ;-) I just thought it ridiculous the
first time I migrated a simple form processing script from PERL to PHP
that I had to change the HTML and the related JavaScript to be
compatible with PHP.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to