Duplicate control names for SELECT tag?

Discussion about HTML and XHTML related issues.
Post Reply
User avatar
moganero
Rank II - Novice
Rank II - Novice
Posts: 30
Joined: Tue Feb 01, 2005 5:47 am
Location: Newcastle under Lyme, UK
Contact:

Duplicate control names for SELECT tag?

Post by moganero » Mon May 08, 2017 5:03 am

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
Site Admin
Posts: 3236
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Duplicate control names for SELECT tag?

Post by Albert Wiersch » Mon May 08, 2017 8:49 am

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.
Image
Albert Wiersch

User avatar
moganero
Rank II - Novice
Rank II - Novice
Posts: 30
Joined: Tue Feb 01, 2005 5:47 am
Location: Newcastle under Lyme, UK
Contact:

Re: Duplicate control names for SELECT tag?

Post by moganero » 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.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3236
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Duplicate control names for SELECT tag?

Post by Albert Wiersch » Mon May 08, 2017 10:42 am

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.
Image
Albert Wiersch

User avatar
moganero
Rank II - Novice
Rank II - Novice
Posts: 30
Joined: Tue Feb 01, 2005 5:47 am
Location: Newcastle under Lyme, UK
Contact:

Re: Duplicate control names for SELECT tag?

Post by moganero » Mon May 08, 2017 11:10 am

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
Site Admin
Posts: 3236
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Duplicate control names for SELECT tag?

Post by Albert Wiersch » Mon May 08, 2017 3:25 pm

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.
Image
Albert Wiersch

Post Reply