mmehari Posted August 6, 2012 Report Share Posted August 6, 2012 Hello everyone, recently i am working on dynamic webdesign and i was trying to specifically access certain tags inside my page. This is the case, i have two paragraph tags with unique ids (i.e. "id_one" and "id_two") and child tags with similar names (i.e. "platform") <p id="id_one"><table><tr><td id="platform"></td></tr></table></p> <p id="id_two"><table><tr><td id="platform"></td></tr></table></p> What i would like to do is to insert content to the second paragraph td tag section.i have two functions named getChildByTagID(parentObj, childID) and getParentByTagName(parentTag) which will search through the page to find the child tag and parent tag accordingly. code section var parentNode = getParentByTagID("id_two");var platformNode = getChildByTagID(parentNode,"platform");document.getElementById(platformNode.id).innerHTML="Text check"; When i do execute the above code i see "Text check" in the first paragraph with id "id_one" not on the second paragraph all i want to is access the second paragraph td tag and write information to it. Thank you for the help,Michael Mehari Link to comment Share on other sites More sharing options...
justsomeguy Posted August 6, 2012 Report Share Posted August 6, 2012 You can't have multiple elements with the same ID, IDs are supposed to be unique on the page. You should use the name attribute for your search function. Other than that, you can update the element directly instead of using document.getElementById. platformNode.innerHTML="Text check"; Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now