On Tue, May 19, 2009 at 10:11 AM, Ford, Mike <m.f...@leedsmet.ac.uk> wrote:
> On 19 May 2009 14:37, Daniele Grillenzoni advised:
>> My complaint is this: a I can have a select multiple with a
>> normal name,
>> which is allowed by every spec, but PHP requires me to use []
>> in order
>> to properly retrieve the values.
> I really don't understand the problem with this -- in fact, I find it
> quite useful to distinguish inputs which may have only 1 value from
> those which may be multi-valued. And it all depends on what you mean by
> a "normal" name, of course -- no current (X)HTML spec disallows [] as
> part of a name attribute, so in that sense a name containing them could
> be seen as perfectly normal...!! ;) ;)
> Can you explain why this is such a hang-up for you, as I haven't seen
> anything in what you've posted so far to convince me it's any kind of
> problem?
> Cheers!
> Mike

I can't speak for the OP, but I've always thought it somewhat odd. An
HTML form should be able to work correctly without modification
regardless of the language that receives the input. As it is, it makes
the HTML for a form implementation specific. You might be able to use
ASP correctly process a form originally targeted toward PHP, but you
could not similarly take a form designed for ASP and process it with
PHP without modification.

It also impacts the use of client-side JavaScript. Consider a simple
page like this:

        function countToppings() {
                var totalToppings = 0;

                var toppings = document.sundae.toppings;
                // To work with PHP, the above line would have to be changed:
                // var toppings = document.sundae.elements['toppings[]'];

                if (toppings.length > 1) {
                        for (var i = 0; i < toppings.length; i++) {
                                if (toppings[i].checked) totalToppings++;
                } else {
                        if (toppings.checked) totalToppings++

                if (totalToppings == 0) {
                        confirm("Are you sure you don't want any toppings on 
your sundae?");
                } else if (totalToppings > 3) {
                        alert("Wow! That's a lot of toppings!");
                } else if (totalToppings == 1) {
                        alert("You only want one topping.");
                } else {
                        alert("You have selected " + totalToppings + " 
toppings! Yummy!");
<form name="sundae">
<input type="checkbox" id="toppings-sprinkles" name="toppings"
value="sprinkles"/> <label
<input type="checkbox" id="toppings-nuts" name="toppings"
value="nuts"/> <label for="toppings-nuts">nuts</label><br/>
<input type="checkbox" id="toppings-fudge" name="toppings"
value="fudge"/> <label for="toppings-fudge">fudge</label><br/>
<input type="checkbox" id="toppings-caramel" name="toppings"
value="caramel"/> <label for="toppings-caramel">caramel</label><br/>
<input type="checkbox" id="toppings-strawberries" name="toppings"
value="strawberries"/> <label
<input type="button" name="count" value="Count My Toppings"
<input type="submit" name="order" value="Order" />

The above form, if submitted, could build a perfectly valid query
string of 

In the grand scheme of things, these are just subtleties that can
easily be handled. Since my first major experience with a web language
was PHP (after a very brief dabble in PERL) before I took a turn at
ASP/VBScript, I'm used to it and it isn't a "hang-up" for me. But
something about it never seemed quite "right" to me either. :-)


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

Reply via email to