0

I have a visualforce page with 2 main sections: "System Administrator" and "Billing Contact" what i want is if the "Same as System Admin" checkbox is checked then the Billing Contact fields get prepopulated with the System Administrator fields.

here's my vf code:

function prepopSA(){
    if(document.getElementById("{!$Component.pg.frm.pbbc1.pbsbc1.chkbc}").checked==true){
    document.getElementById('{!$Component.pg.frm.pbbc2.pbspc2.BC_FN}').value=
    document.getElementById('{!$Component.pg.frm.pbsa1.pbsa2.pbssa2.SA_FN}').value;

}
}


</script>


<apex:form id="frm">
    <apex:pageBlock title="Key Contacts Information" id="pb1">
        <apex:pageBlockSection title="My Company" columns="1" Collapsible="true" id="pb2">
            <apex:inputField value="{!Portal_Key_User_Input__c.Portal_Company__c}" required="true" label="My Company"/>
        </apex:pageBlockSection>

        <apex:pageBlock id="pbsa1">


        <apex:pageBlockSection id="pbssa1" title="System Administrator (This contact is responsible for creating, amending and deleting system users for your organization)" columns="4" Collapsible="true">
            </apex:pageBlockSection>

          <apex:pageBlock id="pbsa2"> 
          <apex:pageBlockSection columns="4" id="pbssa2"> 
            <apex:inputField value="{!Portal_Key_User_Input__c.First_Name1__c}" label="First Name" required="true" id="SA_FN"/>
            <apex:inputField value="{!Portal_Key_User_Input__c.Last_Name1__c}" label="Last Name" required="true" id="SA_LN"/>
            <apex:inputField value="{!Portal_Key_User_Input__c.Email1__c}" label="Email" required="true" Id="SA_E"/>
            <apex:inputField value="{!Portal_Key_User_Input__c.Phone1__c}" label="Phone" required="true" Id="SA_P"/>


            </apex:pageBlockSection>

            </apex:pageBlock>
            </apex:pageBlock>

            <apex:pageBlock id="pbbc1">
           <!-- <apex:pageBlock >-->
            <apex:pageBlockSection id="pbsbc1" title="Billing Contact" columns="4" Collapsible="true">
            <apex:inputField value="{!Portal_Key_User_Input__c.Same_as_System_Admin__c}" id="chkbc" onchange="prepopSA();"/>
            <!--<apex:actionSupport event="onclick" rerender="pbbc2" action="{!sa_bc}" id="asbc"/>
            </apex:inputCheckbox>-->
            <apex:commandButton value="Same as System Admin" action="{!sa_bc}"/> 


            </apex:pageBlockSection>
            <!--</apex:pageBlock>-->

            <apex:pageBlock id="pbbc2" rendered="{!sabc}">
            <apex:pageBlockSection columns="4" id="pbsbc2">

            <apex:inputField value="{!Portal_Key_User_Input__c.First_Name2__c}" label="First Name" id="BC_FN"/>
            <apex:inputField value="{!Portal_Key_User_Input__c.Last_Name2__c}" label="Last Name" ID="BC_LN"/>
            <apex:inputField value="{!Portal_Key_User_Input__c.email2__c}" label="Email" ID="BC_E"/>
            <apex:inputField value="{!Portal_Key_User_Input__c.Phone2__c}" label="Phone" ID="BC_P"/>

            </apex:pageBlockSection>

please help! thank you1

  • what problem are you faicing, could you highlight the problem and point out where in your code you are stuck? If you are new to the platform, Trailheads might be better suited for you. – glls Jan 9 at 22:08
  • so in prepopSA() im checking if "chkbc" is checked and if it is the prepopulate First Name in Billing Contact - "BC_FN" with First Name in System Administrator "SA_FN" – TBan Jan 9 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.