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
badrul Hassanbadrul Hassan 

Please its urgent!!!! This code is for dependend pick list using passing parameter in api. I need to do is using Jquery how to implement and by default value will be all category list in picklist.

This code is for dependend pick list using passing parameter in api. I need to do is using Jquery how to implement and by default value will be all category list in picklist.
When i reload this page by default >All Partners >All Categories >Title video will display 

Visualforce Page:-
 
<apex:page controller="categories" readOnly="true">


    <apex:form id="frm">

     <script>
    function prepareList(parent,child,list,isSubselectOptional){
        $("body").append("<select style='display:none' id='"+parent+child+list+"'></select>");
        $('#'+parent+child+list).html($("#"+list+" option"));
        $('#'+list).html("<option> — </option>");
        $('#'+parent).change(function(){
            var parentValue = $('#'+parent).attr('value');
            $('#'+list).html($("#"+parent+child+list+" .list"+parentValue).clone());
            if(isSubselectOptional) $('#'+list).prepend("<option> — Select — </option>");
        });
    }
    $(function() {        
        prepareList('PartnerId','ContentCategoryId',list, false);
    });
  

</script>


    <script>
   function myJavaMethod(){
      myactionfun();
  }
  </script>
 
 

     
       
     
    
    <apex:pageBlock >
             <apex:pageblockSection columns="3" >
                  <apex:pageBlock >
    
 
              <apex:outputPanel id="testPanel">
                 <Apex:selectlist size="1" value="{!PartnerId}" id="PartnerId" > 
                
                <apex:selectOptions value="{!company}"/> 
                   <apex:actionSupport event="onchange" >
                    </apex:actionSupport> 
                </apex:selectlist>
                   </apex:outputPanel> 
         
                </apex:pageBlock>
        
         
        
    
    
    
  <apex:outputPanel id="testPanel1">
         <apex:pageBlock >
             

                 <apex:selectList size="1" value="{!ContentCategoryId}" id="ContentCategoryId" onclick="myJavaMethod()" >   
                <apex:selectOptions value="{!items}" /> 
                <apex:actionSupport event="onchange" reRender="testPanel">
                </apex:actionSupport>  
                 
                </apex:selectList>
           
               </apex:pageBlock> 
               
         </apex:outputPanel> 
          <apex:outputPanel id="testPanel">
         <apex:pageblock id="pgBlock2"> 
          <!--  <c:PageBlockTableEnhancerADV targetPbTableIds="a"  pageSizeOptions="5,10,15,30,40,50,60,70" defaultPageSize="50" enableExport="false"/> -->
            <apex:pageBlockTable id="list" value="{!performcallout}" var="wrap" width="100%"  rendered="{!normalList}">
            <apex:column headerValue="Title" value="{!wrap.Title}"/>
            <apex:column >
            <apex:inputCheckbox value="{!wrap.selected}" > 
            </apex:inputCheckbox>
            </apex:column>
            </apex:pageBlockTable> 
        </apex:pageBlock> 
        </apex:outputPanel>   
         </apex:pageBlockSection>
         </apex:pageBlock>
 
    </apex:form>
    

</apex:page>

Apex Page :--
 
Public  class categories{
   
    public String ContentCategoryId {get;set;}
    public String PartnerID {get;set;}
  //  public String parentcompany_id{get;set;}
   // PUBLIC List<selectOption> Items;
    public String toAddresses {get; set;}
    
    public   String MySessionID = UserInfo.getSessionID();
    public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
    public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
    public   String Acode= Userinfo.getuserid();
    public   String Oid = UserInfo.getOrganizationId();  
    //phil  
    // Phill public   String Acode= '00530000000rLMxAAM';
   // Phill public   String Oid = '00D300000006YSZEA2';
   //bit9
   // public   String Acode= '00534000008cnnUAAQ';
   //  public   String Oid = '00D28000001G0V0EAK';
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
    
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;} 
    
    public List<videolist> ConsoleWrapperList5{get;set;}
    public string productName{get;set;}
    public integer partner_count{get;set;}
    
    public categories() {
    
   
  // this.ContentCategoryId = 'defaultValue';

       
        getperformcallout6();
        getperformcallout5();
         getperformcallout();
        normalList = true;
        selectedList = false;
     
    }
    public List<companylistwrap> ConsoleWrapperList6{get;set;}
   
    public List<companylistwrap> getperformcallout6(){ 
        ConsoleWrapperList6 = new List<companylistwrap>(); 
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        System.debug('Calling method now' );
        string url = 'https://www.demomail.net/sf/api/PartnerList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+PartnerID;
        //string url = 'https://www.demomail.net/sf/api/PartnerList?AUCode=GlrI5Pb2xh0v3GzK%2FeE8jOX2IG8Kt9lEuzKMJAkgSeiQ6xvUbcgCFlGVG3YURHvJ&SOrgID=Srx%2F%2BRAw%2B9QTiQvLe1h4GBTKvDo3lUBrBU9ksiTTvlW8OWdlQE3Hsj1QQwkgqypL&PartnerId=PartnerId;
        req.setEndpoint(url);
        System.debug('&&: '+ url );
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null)
        {
            ConsoleWrapperList6=(List<companylistwrap>)json.deserialize(res.getbody(),List<companylistwrap>.class);
        }
        return consolewrapperlist6; 
    }
    public List<SelectOption> getcompany() {
        List<SelectOption> options = new List<SelectOption>();
                   
                  // options.add(new SelectOption('null','-Select-'));
                    options.add(new SelectOption('0','All Partners'));
                    
        for(companylistwrap crRec : ConsoleWrapperList6){
        
        options.add(new SelectOption(crRec.PartnerID, crRec.PartnerName));
               
  
        } 
        
        
          partner_count= options.size();
          getperformcallout5();
          System.debug('##: '+  partner_count);
        return options;
    }
    public List<videolist> getperformcallout5(){ 
        ConsoleWrapperList5 = new List<videolist>(); 
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        System.debug('Calling method now' );
   
      // string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode=GlrI5Pb2xh0v3GzK%2FeE8jOX2IG8Kt9lEuzKMJAkgSeiQ6xvUbcgCFlGVG3YURHvJ&SOrgID=Srx%2F%2BRAw%2B9QTiQvLe1h4GBTKvDo3lUBrBU9ksiTTvlW8OWdlQE3Hsj1QQwkgqypL&CategoryId=4788&LanguageId=0&PartnerId=1227';
        string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+PartnerID;
        req.setEndpoint(url);
        System.debug('**: '+ url );
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null)
        {
            ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class);
        }
        return consolewrapperlist5; 
    }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
                  
                    
            for(videolist crRec : ConsoleWrapperList5){
                options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName));
                System.debug('##: '+ crRec.ContentCategoryId);
            }  
            partner_count= options.size(); 
             getperformcallout();
        return options;
       
    }
    public List<consolewrap> ConsoleWrapperList{get;set;}
    public  List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+PartnerID;
        System.debug('@@: '+ url);
        req.setEndpoint(url);
        //System.debug('!!!'+ SessionId);
        req.setMethod('GET');
        //system.debug('???'+aucode);
        //system.debug('***'+ocode);
        res = http.send(req);
        // System.assert(false,res.getBody()+'-----');
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
        
        return ConsoleWrapperList;
    } 
    
    public pageReference getperformcalloutpageReference ()
    {
        getperformcallout(); 
        return null; 
    } 
    
    public pageReference getcompanypageReference ()
    {
        getperformcallout5();
        return null; 
    }  
    
     
}