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
WarjieWarjie 

Get dropdown value

hi, i have a vf page consists of 2 pages. But these 2 pages only use 1 controller. Here's what i need to do, if you select a value from the dropdown in page 1, the other dropdown from page2 will display only the approriate values depending on the value you chose in dropdown 1. here's part of the code:

 

    public List<SelectOption> getCampusLocations() {
    	
        List<SelectOption> options = new List<SelectOption>();
        //this.vfhFormRecord.VET_Qualification__c
        
        Set<String> locationNames = new Set<String>();
        /*
        for(Locations__c loc: [Select Id, Name from Locations__c WHERE RecordType.DeveloperName = 'Training_Delivery_Location' Order By Name ] ) {
            options.add(new SelectOption(loc.Id, loc.Name)); 
        }*/
        
        //filter the parent location names from qualification locations related to the qualification selected
        Set<Id> qualificationIds = new Set<Id>();
        Set<String> commonNameCheck = new Set<String>();
        
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        
        
        for(Qualification_Location__c qLoc: [Select Location__r.Name from Qualification_Location__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(qLoc.Location__r.Name)) {
                commonNameCheck.add(qLoc.Location__r.Name);
                locationNames.add(qLoc.Location__r.Name);
            }
        }
            
        //filter the locations using the location names and vet provider
        if(locationNames.size()>0) {
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name = 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name));
            }
        
            for(Locations__c loc: [Select Id, Name 
                                    from Locations__c 
                                    WHERE RecordType.DeveloperName = 'Training_Delivery_Location' 
                                        AND Training_Organisation__c =: this.vfhFormRecord.VET_Provider__c
                                        AND Name IN: locationNames AND Name != 'Bowen Hills'] ) {
                options.add(new SelectOption(loc.Id, loc.Name)); 
            }

        }
        
        return options; 
    }

 

    public List<SelectOption> getDeliveryModes() {
        List<SelectOption> options = new List<SelectOption>();
        Set<Id> qualificationIds = new Set<Id>();
        qualificationIds.add(this.vfhFormRecord.VET_Qualification__c);
        if(this.ddMapping!=null) {
            qualificationIds.add(this.ddMapping.Qualification2__c);
        }
        Set<String> commonNameCheck = new Set<String>();
        for(Qualification_Delivery_Mode__c dqm: [Select Delivery_Mode__c, Delivery_Mode_Common_Name__c from Qualification_Delivery_Mode__c WHERE Qualification__c IN: qualificationIds] ) {
            if(!commonNameCheck.contains(dqm.Delivery_Mode_Common_Name__c)) {
                commonNameCheck.add(dqm.Delivery_Mode_Common_Name__c);
                options.add(new SelectOption(dqm.Delivery_Mode__c, dqm.Delivery_Mode_Common_Name__c)); 
            }
        }

        return options; 
    }

 here's the vf page:

 

            <table width="100%" style="width:100%;">
                <tr>
                    <td colspan="4" class="tableHeader">
                        <apex:outputText value="Qualification Details"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <apex:outputLabel value="I wish to apply to study in the following mode* :" for="DeliveryModeFrm1"/>
                    </td>
                    <td>
                        <apex:selectList size="1" value="{!vfhFormRecord.Delivery_Mode_Type__c}" id="DeliveryModeFrm1">
                            <apex:selectOptions value="{!DeliveryModes}"/>
                        </apex:selectList>
                    </td>
                    <td colspan="2" style="width:50%">
                        &nbsp;
                    </td>
                </tr>
            </table>

 so what i do for get and set of the apexlist is this: (which is i know totally wrong)

 

    //DeliveryModeFrm1
 	public String[] getVfhFormRecord.Delivery_Mode_Type__c(){
        return this.selectedDelivery;
    }
    
    public void setVfhFormRecord.Delivery_Mode_Type__c(String[] selectedDelivery){
        this.selectedDelivery = selectedDelivery;
    }

 can anyone give me an idea how can i get the selected value from dropdown 1?

 

thanks very much

WarjieWarjie
so i want to add a filter in getCampusLocations once i get the value chosen in the dropdown1