You need to sign in to do that
Don't have an account?
problem in getting changed value of picklist
I have one picklist with me, and i am trying to get the selected value of the picklist. below is the code
VF page :
<apex:outputlabel value="Select City" for="values" />
<apex:actionSupport event="onchange" action="{!getcitylist}" rerender="txt_city"/>
<apex:selectList value="{!cities}" size="1">
<apex:selectOptions value="{!showcities}"/>
</apex:selectList>
<apex:inputText id="txt_city"/>
Apex Code :
String sel_city;
public String cities
{
get {return sel_city;}
set {sel_city=value;}
}
public List<selectOption> getshowcities()
{
List<selectOption> Selectcity = new List<selectOption>();
List<Regstr__c> citylist = new List<Regstr__c>();
courselist = [Select id, city_name__c FROM Regstr__c ];
SelectCourse.add(new SelectOption('0','Select city'));
for (Integer j=0;j<citylist .size();j++)
{
Selectcity .add(new SelectOption(citylist [j].id,citylist [j].city_name__c));
}
return Selectcity ;
}
public void getcitylist() //this function is called onchange event of dropdown
{
//once the selected item in the city drop down is changes, here i have to save the selected value of "city"dropdown list in textbox "txt_city"
}
I am new to salesforce, please suggest me how to write the scipt to save the value of dropdown in textbox.
Thanks in advance!!!!!!!!!!!!!!!!!!!!!!
All Answers
String sel_city; public String cities { get {return sel_city;} set {sel_city=value;} }
With this:
public String cities {get; set;}
<apex:inputText id="txt_city"/>
to this:
<apex:inputText id="txt_city" value="{!cities}/>