Jump to content

Mulitple Ids In A Single <select>, Etc.


Recommended Posts

</div><b>Location:</b><table style='width:100%; position:relative; '><tr><th style='width:50%'><a href='java script:;' id='field_location' class='addnode_select_link'>Select</a> Location already available</th><th style='width:50%'>or <a href='java script:;' class='addnode_item field_location' id='location'><span id='field_location' class='addnode_links'>create a new Location</span></a></span></th></tr><tr><td style='vertical-align:top;'><div class="form-item"><select name="field_location[nhids][]" multiple="multiple"  style="width:90%" class="form-select required addnode_select" id="field_location" id="edit-field-location-nids"  size="15">

In the preceding code, the <select> tag has two id fields. Furthermore the <a> tag just above it has an id that is the same as the first id in the select (unless the use of single quotes versus double quotes makes a difference). When I looked up "id" at http://www.w3schools.com/tags/att_standard_id.asp I read that 1. The id attribute specifies a unique id for an HTML element.2. The id must be unique within the HTML document.Can someone explain this to me?Thanks,Jerry

Link to comment
Share on other sites

i see you are trying to use an id multiple times also... if you plan to use something more than once within a page, you need to use class instead of id

Link to comment
Share on other sites

when you want to call an element using javascript and you call it by id, that's wy it has to be unique on the page.If u don't use any scripting it's not a problem but you really should use class instead.

Link to comment
Share on other sites

when you want to call an element using javascript and you call it by id, that's wy it has to be unique on the page.If u don't use any scripting it's not a problem but you really should use class instead.
Thanks for the reply. This is not my code but some I was looking at on the Web. When I read that the id had to be unique, I was assuming that someone was enforcing this. I believe what you are telling me is that this is the convention that you should follow if you want to use JavaScript with in a web page, but that nobody enforces this rule.Jerry
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...