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
Walter@AdicioWalter@Adicio 

I cant figure out how to work on the value selected by the user in the selectList

Can someone help me understand the correct way to access the value selected by the user in the selectList and run some logic against the selection?

 

This is not working for me. Its for a jump to page drop list in a visualforce wizard.

 

 

public String[] jumpToSelections = new String[]{}; string selectedJumpTo = ''; public pageReference test() { if(jumpToSelections!=null){selectedJumpTo=jumpToSelections[0];} if(selectedJumpTo!=null && selectedJumpTo=='1'){return Page.step1;} if(selectedJumpTo!=null && selectedJumpTo=='2'){return Page.step2;} return null; } public List<SelectOption> getJumpToItems() { List<SelectOption> jumpToOptions = new List<SelectOption>(); jumpToOptions.add(new SelectOption('0','')); jumpToOptions.add(new SelectOption('1','Step 1')); jumpToOptions.add(new SelectOption('2','Step 2')); return jumpToOptions; } public String[] getJumpToSelections() { return jumpToSelections; } public void setJumpToSelections(String[] jumpToSelections) { this.jumpToSelections = jumpToSelections; }

 

 

Thank you.

Best Answer chosen by Admin (Salesforce Developers) 
jeffdonthemic2jeffdonthemic2

Take a look at this blog post. It has 3 dependent picklists and shows the Visualforce and Apex code.

 

Dependent Multilevel Selectlists

 

Jeff Douglas

Appirio, Inc.

http://blog.jeffdouglas.com 

All Answers

jeffdonthemic2jeffdonthemic2

Take a look at this blog post. It has 3 dependent picklists and shows the Visualforce and Apex code.

 

Dependent Multilevel Selectlists

 

Jeff Douglas

Appirio, Inc.

http://blog.jeffdouglas.com 

This was selected as the best answer
sfdcfoxsfdcfox

It's just as easy as this:

 

 

<apex:inputSelect value="{!selectedOption}"> <apex:selectOptions value="{!selectList}"/> </apex:inputSelect>

 

public class testPageController { public list<selectoption> getSelectList() { // make your list here. } public string selectedOption { get; set; } }

 

 

 

Walter@AdicioWalter@Adicio

Thank you. Below is what is working for me.

 

public string selectedLevel1 {get; set;} public List<SelectOption> level1Items { get{ List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('','-- Choose a Step --')); options.add(new SelectOption('1','Step 1. Opportunity, Pricebook, Account, Contact')); options.add(new SelectOption('2','Step 2. Quote')); options.add(new SelectOption('3','Step 3. Products')); options.add(new SelectOption('4','Step 4. Quote Line Items')); options.add(new SelectOption('5','Step 5. Comments')); options.add(new SelectOption('6','Step 6. Sort, Save')); options.add(new SelectOption('7','Step 7. Preview')); return options; } set; } public pageReference jump() { if(selectedLevel1=='1'){selectedLevel1=null; return step1();} if(selectedLevel1=='2'){selectedLevel1=null; return step2();} if(selectedLevel1=='3'){selectedLevel1=null; return step3();} if(selectedLevel1=='4'){selectedLevel1=null; return step4();} if(selectedLevel1=='5'){selectedLevel1=null; return step5();} if(selectedLevel1=='6'){selectedLevel1=null; return step6();} if(selectedLevel1=='7'){selectedLevel1=null; return step7();} return null; }