Duplicate control names for SELECT tag?

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
User avatar
moganero
Rank II - Novice
Posts: 40
Joined: Tue Feb 01, 2005 5:47 am
Location: Newcastle under Lyme, UK

Duplicate control names for SELECT tag?

Post 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.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Duplicate control names for SELECT tag?

Post 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.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
moganero
Rank II - Novice
Posts: 40
Joined: Tue Feb 01, 2005 5:47 am
Location: Newcastle under Lyme, UK

Re: Duplicate control names for SELECT tag?

Post 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.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Duplicate control names for SELECT tag?

Post 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.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
moganero
Rank II - Novice
Posts: 40
Joined: Tue Feb 01, 2005 5:47 am
Location: Newcastle under Lyme, UK

Re: Duplicate control names for SELECT tag?

Post 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).
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Duplicate control names for SELECT tag?

Post 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.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial