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
NaypersMclgxNaypersMclgx 

selectlist options that depends on other selectlist

hi everyone, I hope somebody can helpme, I try to have options in a selectlist that depends on another, I have this but I dont know what's wrong

 

VISUAL FORCE

 

<apex:page controller="myController" >
    <apex:form >
    
        <apex:selectList id="selectlist1" value="{!select1}" size="1">
            <apex:actionSupport event="onclick" reRender="selectlist2"/>
            <apex:selectOptions value="{!items}"/>    
        </apex:selectList>
         
        <apex:selectList id="selectlist2" value="{!select2}" size="1">
            <apex:selectOptions value="{!items2}"/>    
        </apex:selectList>
        
    </apex:form>
</apex:page>

APEX CODE

 

public class myController {

    public string select1{get; set;}
    public string select2{get; set;}

    public List<SelectOption> getItems()
    {
        List<SelectOption> option = new List<SelectOption>(); 
            option.add(new SelectOption('op1','Option 1'));
            option.add(new SelectOption('op2','Option 2'));
            option.add(new SelectOption('op3','Option 3'));
        return option;
    }
 
    public List<SelectOption> getItems2()
    {
        List<SelectOption> option = new List<SelectOption>();
        if( select1 == 'op3')
            {
                option.add(new SelectOption('op3_1','Option 3.1'));
                option.add(new SelectOption('op3_2','Option 3.2'));
                option.add(new SelectOption('op3_3','Option 3.3'));
            }
        return option;
    }
 
}

 

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

Whats wrong with your code... it is working as expected.What exactly are you expecting out of this?