Page 1 of 1

Duplicate control names for SELECT tag?

Posted: Mon May 08, 2017 5:03 am
by moganero
I have just been using the same control name, counties[] for several SELECT inputs so that counties in England, Scotland, Wales and Ireland in each are are all passed as values for the same parameter to the PHP script handling it.
HTML Validator gives a warning "[119] The control name "counties_covered[]" has already been used in this form and should not be used in this "select" tag." for this.
The technique appears to work OK - has anyone else tried this and encountered problems?
If not, should the should the warning given continue with something like "unless this was intended"?

Edit:
I suppose it would be a problem if Javascript were involved.

Re: Duplicate control names for SELECT tag?

Posted: Mon May 08, 2017 8:49 am
by Albert Wiersch
Hello,

Thanks for reporting this.

Perhaps the best solution is to just ignore this "issue" if the control name ends in "[]"? Or change the message to a regular (non-warning/non-error) message? Which do you think would be better (more useful to developers)?

UPDATE: The message should now read like this:
[119] The control name "counties_covered[]" for this "select" tag has already been used in this form. Ensure that this is intended.

Re: Duplicate control names for SELECT tag?

Posted: Mon May 08, 2017 10:03 am
by moganero
It probably is better as just an informative message rather than a warning, but I'd stand corrected if there is good reason it shouldn't be done.

Re: Duplicate control names for SELECT tag?

Posted: Mon May 08, 2017 10:42 am
by Albert Wiersch
moganero wrote:
Mon May 08, 2017 10:03 am
It probably is better as just an informative message rather than a warning, but I'd stand corrected if there is good reason it shouldn't be done.
Do you mean that when the name ends in "[]" to indicate an array, that the message should be an informational message instead of a warning? I could certainly do this, but I'm thinking that suppressing the message entirely (when the name ends in "[]") might be the better way to go. Do you see any issues with just suppressing the message entirely (when the name ends in "[]")? I think that is what I will do unless there is a good reason to justify an informational message instead of a total message suppression.

I don't think there is any reason using "[]" for arrays and using the same array name more than once shouldn't be done where it is wanted or needed, and used properly of course.

Re: Duplicate control names for SELECT tag?

Posted: Mon May 08, 2017 11:10 am
by moganero
I think you're right, there's no need for a message at all if it is an array that is being passed unless there is another reason that the user should be alerted, such as the control name being used by Javascript (which I'm not very well up on).

Re: Duplicate control names for SELECT tag?

Posted: Mon May 08, 2017 3:25 pm
by Albert Wiersch
Great. That's what I'll do then for the next update. I don't want to alert users with warnings for issues that are very likely to be as intended.