function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to traverse through ids by document.getElementById..

I have different levels







Every level has their ids.Now in JScript I want to traverse through ids by to traverse ?Directly using .inputfield id is not working,,,,,Suggestion please!


I'm not entirely clear on your problem.  Are you just trying to select the specific input element and are not sure what the id is?


Just make sure you give the element an id - so your Visualforce code should look like <apex:inputfield id="myInputField" />.  Salesforce will give it an ID but they append an enumeration for each parent element.  So, if your page looks like this:


Apex:page id="page"

2.form id="form"

3.pageblock id="block"

3.pageblocksection id="section"

4.inputfield id="myInputField"


Your input field will be rendered with an id that looks like this: id="page:form:block:section:myInputField"


If you use document.getElementByID('page:form:block:section:myInputField') that should grab it.  If you aren't sure of the name, just view the page source and grab the id of the input field from there.