You need to sign in to do that
Don't have an account?

how to Return one particular value that is selected by selectlist compontant [new]
hi all,
we i want to return one particular item(value) that is selected by selectlist compontant
for example in my code there is selectlist compontan also 1 selectoptions compant which contains three value like us,canada,maxico
now i want to return one selected value
suppose if i select canada than i want to return canada
here is my code
page code
controller code
we i want to return one particular item(value) that is selected by selectlist compontant
for example in my code there is selectlist compontan also 1 selectoptions compant which contains three value like us,canada,maxico
now i want to return one selected value
suppose if i select canada than i want to return canada
here is my code
page code
Code:
<apex:page controller="sampleCon"> <apex:form> <apex:selectlist value="{!countries}" title="Choose a country" size="1" required="true"> <apex:selectOptions value="{!items}" /> </apex:selectlist><br/> <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/> </apex:form> <apex:outputPanel id="out"> <apex:actionstatus id="status" startText="testing..."> <apex:facet name="stop"> <apex:outputPanel> <p>You have selected:</p> <apex:datatable value="{!countries}" var="c"> <apex:column value="{!c}"/> </apex:datatable> </apex:outputPanel> </apex:facet> </apex:actionstatus> </apex:outputPanel> </apex:page>
Code:
/*** Controller: ***/ public class sampleCon { String[] countries = new String[]{}; public PageReference test() { return null; } 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; }
its working thanks a lot buddy