I'm having two pick list based on 1st picklist values 2nd picklist must be displayed. I tried in two ways but its not working.
Way 1: using rerendered in VF page
<apex:pageBlockSectionItem >
<apex:outputLabel value="Item" for="item"/>
<apex:selectList id="item" value="{!selectedItem}" size="1">
<apex:selectOptions value="{!items}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Colum Two" for="Two"/>
<apex:selectList id="Two" value="{!selectedItem1 }" rendered="{!selectedItem == 'Math JrBg || Math SrBg|| Math 0a || English SrBg || Abacus Jr Level 2 || Abacus Sr Level 1 || Abacus Jr Level 1 || Abacus Sr Level 2' }" size="1">
<apex:selectOptions value="{!items1}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
public List<SelectOption> getItems()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('--Select an Item--','--Select an Item--'));
options.add(new SelectOption('Pens - Qty 50' , 'Pens - Qty 50'));
options.add(new SelectOption('Pencils - Qty 50','Pencils - Qty 50'));
options.add(new SelectOption('Blue Draw String Bags - Qty 10','Blue Draw String Bags - Qty 10'));
options.add(new SelectOption('BestBrains Bags-Zip Type - Qty 50','BestBrains Bags-Zip Type - Qty 50'));
options.add(new SelectOption('$1 Bucks - Qty 500 pcs','$1 Bucks - Qty 500 pcs'));
options.add(new SelectOption('$10 Bucks - Qty 500 pcs','$10 Bucks - Qty 500 pcs'));
options.add(new SelectOption('Progress Books - Qty 20','Progress Books - Qty 20'));
options.add(new SelectOption('Abacus Tools - Qty 20','Abacus Tools - Qty 20'));
options.add(new SelectOption('Master Abacus - Qty 1 ','Master Abacus - Qty 1 '));
options.add(new SelectOption('Parent Curriculum Charts - Qty 20','Parent Curriculum Charts - Qty 20'));
options.add(new SelectOption('Owner Curriculum Chart - Qty 1','Owner Curriculum Chart - Qty 1'));
options.add(new SelectOption('Math Certificates - Qty 20','Math Certificates - Qty 20'));
options.add(new SelectOption('English Certificates - Qty 20','English Certificates - Qty 20'));
options.add(new SelectOption('Abacus Certificates - Qty 20','Abacus Certificates - Qty 20'));
options.add(new SelectOption('General Knowledge Certificates - Qty - 20','General Knowledge Certificates - Qty - 20'));
options.add(new SelectOption('Abacus JR Level 1 Workbook - Qty 10' , 'Abacus JR Level 1 Workbook - Qty 10'));
options.add(new SelectOption('Math JrBg' , 'Math JrBg'));
options.add(new SelectOption('Math SrBg','Math SrBg'));
options.add(new SelectOption('Math 0a','Math 0a'));
options.add(new SelectOption('English SrBg','English SrBg'));
options.add(new SelectOption('Abacus Jr Level 1','Abacus Jr Level 1'));
options.add(new SelectOption('Abacus Jr Level 2','Abacus Jr Level 2'));
options.add(new SelectOption('Abacus Sr Level 1','Abacus Sr Level 1'));
options.add(new SelectOption('Abacus Sr Level 2','Abacus Sr Level 2'));
return options ;
}
public List<SelectOption> getItems1()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('A - Qty 5','A - Qty 5'));
options.add(new SelectOption('B - Qty 5','B - Qty 5'));
options.add(new SelectOption('C - Qty 5','C - Qty 5'));
options.add(new SelectOption('D - Qty 5','D - Qty 5'));
options.add(new SelectOption('E - Qty 5','E - Qty 5'));
options.add(new SelectOption('F - Qty 5','F - Qty 5'));
options.add(new SelectOption('G - Qty 5','G - Qty 5'));
options.add(new SelectOption('H - Qty 5','H - Qty 5'));
options.add(new SelectOption('I - Qty 5','I - Qty 5'));
options.add(new SelectOption('J - Qty 5','J - Qty 5'));
options.add(new SelectOption('K - Qty 5','K - Qty 5'));
options.add(new SelectOption('L - Qty 5','L - Qty 5'));
options.add(new SelectOption('M - Qty 5','M - Qty 5'));
options.add(new SelectOption('N - Qty 5','N - Qty 5'));
options.add(new SelectOption('O - Qty 5','O - Qty 5'));
options.add(new SelectOption('P - Qty 5','P - Qty 5'));
options.add(new SelectOption('Q - Qty 5','Q - Qty 5'));
options.add(new SelectOption('R - Qty 5','R - Qty 5'));
options.add(new SelectOption('S - Qty 5','S - Qty 5'));
options.add(new SelectOption('T - Qty 5','T - Qty 5'));
options.add(new SelectOption('U - Qty 5','U - Qty 5'));
options.add(new SelectOption('V - Qty 5','V - Qty 5'));
options.add(new SelectOption('W - Qty 5','W - Qty 5'));
options.add(new SelectOption('X - Qty 5','X - Qty 5'));
options.add(new SelectOption('Y - Qty 5','Y - Qty 5'));
options.add(new SelectOption('Z - Qty 5','Z - Qty 5'));
return options ;
}
Way 2 :: Using IF condition in controller
<apex:pageBlockSectionItem >
<apex:outputLabel value="Item" for="item"/>
<apex:selectList id="item" value="{!selectedItem }" size="1">
<apex:selectOptions value="{!items}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Colum Two" for="Two"/>
<apex:selectList id="Two" value="{!selectedItem1 }" size="1">
<apex:selectOptions value="{!items1}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
public List<SelectOption> getItems()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('--Select an Item--','--Select an Item--'));
options.add(new SelectOption('Pens - Qty 50' , 'Pens - Qty 50'));
options.add(new SelectOption('Pencils - Qty 50','Pencils - Qty 50'));
options.add(new SelectOption('Blue Draw String Bags - Qty 10','Blue Draw String Bags - Qty 10'));
options.add(new SelectOption('BestBrains Bags-Zip Type - Qty 50','BestBrains Bags-Zip Type - Qty 50'));
options.add(new SelectOption('$1 Bucks - Qty 500 pcs','$1 Bucks - Qty 500 pcs'));
options.add(new SelectOption('$10 Bucks - Qty 500 pcs','$10 Bucks - Qty 500 pcs'));
options.add(new SelectOption('Progress Books - Qty 20','Progress Books - Qty 20'));
options.add(new SelectOption('Abacus Tools - Qty 20','Abacus Tools - Qty 20'));
options.add(new SelectOption('Master Abacus - Qty 1 ','Master Abacus - Qty 1 '));
options.add(new SelectOption('Parent Curriculum Charts - Qty 20','Parent Curriculum Charts - Qty 20'));
options.add(new SelectOption('Owner Curriculum Chart - Qty 1','Owner Curriculum Chart - Qty 1'));
options.add(new SelectOption('Math Certificates - Qty 20','Math Certificates - Qty 20'));
options.add(new SelectOption('English Certificates - Qty 20','English Certificates - Qty 20'));
options.add(new SelectOption('Abacus Certificates - Qty 20','Abacus Certificates - Qty 20'));
options.add(new SelectOption('General Knowledge Certificates - Qty - 20','General Knowledge Certificates - Qty - 20'));
options.add(new SelectOption('Abacus JR Level 1 Workbook - Qty 10' , 'Abacus JR Level 1 Workbook - Qty 10'));
options.add(new SelectOption('Math JrBg' , 'Math JrBg'));
options.add(new SelectOption('Math SrBg','Math SrBg'));
options.add(new SelectOption('Math 0a','Math 0a'));
options.add(new SelectOption('English SrBg','English SrBg'));
options.add(new SelectOption('Abacus Jr Level 1','Abacus Jr Level 1'));
options.add(new SelectOption('Abacus Jr Level 2','Abacus Jr Level 2'));
options.add(new SelectOption('Abacus Sr Level 1','Abacus Sr Level 1'));
options.add(new SelectOption('Abacus Sr Level 2','Abacus Sr Level 2'));
return options ;
}
public List<SelectOption> getItems1()
{
List<SelectOption> options = new List<SelectOption>();
if(selectedItem == 'Abacus Sr Level 2')
options.add(new SelectOption('A - Qty 5','A - Qty 5'));
options.add(new SelectOption('B - Qty 5','B - Qty 5'));
options.add(new SelectOption('C - Qty 5','C - Qty 5'));
options.add(new SelectOption('D - Qty 5','D - Qty 5'));
options.add(new SelectOption('E - Qty 5','E - Qty 5'));
options.add(new SelectOption('F - Qty 5','F - Qty 5'));
options.add(new SelectOption('G - Qty 5','G - Qty 5'));
options.add(new SelectOption('H - Qty 5','H - Qty 5'));
options.add(new SelectOption('I - Qty 5','I - Qty 5'));
options.add(new SelectOption('J - Qty 5','J - Qty 5'));
options.add(new SelectOption('K - Qty 5','K - Qty 5'));
options.add(new SelectOption('L - Qty 5','L - Qty 5'));
options.add(new SelectOption('M - Qty 5','M - Qty 5'));
options.add(new SelectOption('N - Qty 5','N - Qty 5'));
options.add(new SelectOption('O - Qty 5','O - Qty 5'));
options.add(new SelectOption('P - Qty 5','P - Qty 5'));
options.add(new SelectOption('Q - Qty 5','Q - Qty 5'));
options.add(new SelectOption('R - Qty 5','R - Qty 5'));
options.add(new SelectOption('S - Qty 5','S - Qty 5'));
options.add(new SelectOption('T - Qty 5','T - Qty 5'));
options.add(new SelectOption('U - Qty 5','U - Qty 5'));
options.add(new SelectOption('V - Qty 5','V - Qty 5'));
options.add(new SelectOption('W - Qty 5','W - Qty 5'));
options.add(new SelectOption('X - Qty 5','X - Qty 5'));
options.add(new SelectOption('Y - Qty 5','Y - Qty 5'));
options.add(new SelectOption('Z - Qty 5','Z - Qty 5'));
return options ;
}