+ Start a Discussion

ID's of input fields generated in VF

Should I expect the following Visualforce code
#1 Code:
<apex:inputField id="aFirstName" value="{!a.First_Name__c}"/>

 to generate the following HTML (assume the defined salesforce field type is standard text)?
#2 Code:
<input type="text" id="aFirstName" value="">

The reason I ask is because when I create a standard html input text box (like the one in #2 above) and use script to set its value using:


it works fine but as soon as I convert it to a Visualforce input field (like the one in #1 above) the browser fails to locate the field with the id of "aFirstName".  Does VF alter the ID specified in the inputField tag when generating HTML?  Since I can't view source it is impossible for me to tell.





DOM ids are generated by VF from the id attribute of the component and its containers to ensure they are unique. 

You can obtain the generated dom id for a component by usign the $Component global variable. 

See the description of $Component in the developer quide. 


fantastic..thanx for the quick response.  Of course it's in a part of the guide I only skimmed.

I'll take another look.


Message Edited by thedge on 12-19-2007 03:09 PM