user188962
user188962

Reputation:

Is there any way to have multiple ID:s with same name in one HTML document?

I have a form which has several tags.

is this possible:

   <select name="select1" id="select1">
       <option id="1990" value="1990">1990</option>
       <option id="1991" value="1991">1991</option>
   </select>

   <select name="select2" id="select2">
       <option id="1990" value="1990">1990</option>
       <option id="1991" value="1991">1991</option>
   </select>

The ID are the same...

Thanks

Upvotes: 1

Views: 3364

Answers (1)

Sarfraz
Sarfraz

Reputation: 382666

No id can be assigned only once since it is an identity for just a single element. You need to use class instead but i wonder why you need to assign same ids? If you assign same ids to more than one element, and use javascript, etc to manipulate it, then only last element with same id will be taken care of ignoring all previous elements....

For more information, please see:

ID vs CLASS

Upvotes: 7

Related Questions