• Brinel
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

I have the following code.
When Subcategory is Retailer Street, another field called Chain should appear but i get the following error in popup: 
ReferenceError: Customer_Seling_Type__c is not defined

Can anyone help me please?
<apex:page standardController="Customer_Seling_Type__c" id="pg">
      <apex:form id="frm">
            <apex:pageBlock title="Javascript Example" id="pgBlock" >
                 <apex:pageBlockSection title="Checkbox Example" id="pbSec"> 
                      <apex:inputField id="cc" value="{!Customer_Seling_Type__c.Subcategory__c}" label="Do not call" onchange="tt(this);"/>
                      <apex:pageBlockSectionItem id="pbsi">
                          <apex:outputLabel value="Languages" id="lblLang" ></apex:outputLabel>
                          <apex:inputField id="languageCtrl" value="{!Customer_Seling_Type__c.Chain__c}" />
                      </apex:pageBlockSectionItem>
                 </apex:pageBlockSection>
            </apex:pageBlock>
      
      </apex:form>

      <script>
         function tt(chkboxCtrl) {
         
             try {
                      // hide if checked
                      if( Customer_Seling_Type__c.Subcategory__c =="Retailer Street" ) {
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.languageCtrl}').style.display = 'inline';
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.lblLang}').style.display = 'inline';
                      }
                      else {
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.languageCtrl}').style.display = 'none';
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.lblLang}').style.display = 'none';
                      }
                      
                      
              }
              catch(e) {
                  alert(e);
              }
         }
         
         document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.languageCtrl}').style.display = 'none';
         document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.lblLang}').style.display = 'none';
         
   </script>   
</apex:page>