kilp-web@sbcglobal.net Posted June 8, 2009 Share Posted June 8, 2009 </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 More sharing options...
smerny Posted June 8, 2009 Share Posted June 8, 2009 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 More sharing options...
cedric Posted June 8, 2009 Share Posted June 8, 2009 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 More sharing options...
kilp-web@sbcglobal.net Posted June 8, 2009 Author Share Posted June 8, 2009 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 More sharing options...
cedric Posted June 8, 2009 Share Posted June 8, 2009 that's it. Or that's what I think is correct, but i'm also fearly new at this. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.