You need to sign in to do that
Don't have an account?
Anjaan
How to set default value in select list
Hello All
I am using <apex:selectlist size = "1"> for making a select box. \
i have a number of selectlists and want to show the same data in them but i have to set the different selected values on each list. Here is my Code
and the page...
both are showing the same value "USA" i want to show CANADA on the second list by default.......
Please help me
I am using <apex:selectlist size = "1"> for making a select box. \
i have a number of selectlists and want to show the same data in them but i have to set the different selected values on each list. Here is my Code
Code:
My Controller public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; } public String[] getCountries(){ return countries; } public void setCountries(String[] countries){ this.countries = countries; }
and the page...
Code:
<apex:selectList value="{!countries}" size="1" required="true"> <apex:selectOptions value="{!items}"/> </apex:selectList> <apex:selectList value="{!countries}" size="1" required="true"> <apex:selectOptions value="{!items}"/> </apex:selectList>
both are showing the same value "USA" i want to show CANADA on the second list by default.......
Please help me
something like this:
Another technique you could use (I do) is to create a "dummy" entry at the top that forces the user to select something.
For the first option add code, do something like this:
then you can test to make sure that some value was selected.