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
Sekhar SekharSekhar Sekhar 

what is the use of id in Visual force pages

Hi  Friends
I have a small doubt that is what is the use of “ id” in visual force pages and how to use ,when to use these “id ” in vf page
Ex:1  <apex:pageBlock id="theBlock">
Ex:2  <apex:pageBlockSection title="Information" id="et">

 
Sneha Shende 19Sneha Shende 19
Hello,
"An identifier that allows the pageBlock component to be referenced by other components in the page". Basically it allows you to select that pageBlock using Javascript, CSS and other web methods.
If you are trying to access the component from within the visualforce using javascript/jquery you need to access it by id.
Shruti khodaboleShruti khodabole
Hi,
An id is used to access value in javascript or in apex class etc,for example 
Use  javascript to get an element from the page, -refer below code how id is access in javascript
<apex:page standardController="Account" showHeader="true" sidebar="true">
    <apex:form id="apForm">
        <apex:pageBlock id="accountPlanEdit">
            <apex:pageBlockSection id="globalAddress">
                <apex:inputfield value="{!Account.Name}" id="globalHQCity" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <script type="text/javascript">
        var GHCity = document.getElementById('{!$Component.apForm.accountPlanEdit.globalAddress.globalHQCity}').value;
        alert(GHCity);
    </script>
</apex:page>

Thanks,
Shruti Khodabole
Salesforce Developer
http://www.zen4orce.com