You need to sign in to do that
Don't have an account?
balu palavalasa
hi i am beginner to salesforce
hi i am a beginner in salesforce.i have a requirement . there are 2 sections in a vf page .in first section there is only one input textbox which takes values for a country field . and a button called "add" once this button is clicked in the backend it has to add the value in country textbox to a selectlist. so how many times we click on add button those many values must be added to select list.there is another button submit. once submit button is clicked the country list must be displayed in 2nd pageblock section . how can i achieve this
vf page code is :
<apex:page Controller="selectlistoption">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputlabel value="Enter Country"/>
<apex:inputText value="{!str}"/>
<apex:commandButton value="Add" action="{!setCountry}"/>
<apex:commandButton value="submit" rerender="showdetails"/>
</apex:pageBlockSection>
<apex:pageBlockSection id="showdetails">
<apex:selectlist size="1" value="{!str}">
<apex:selectoptions value="{!country}"/>
</apex:selectlist>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
------------------------------------------------------------------------apex code -------------------------------------------------------------
public class selectlistoption {
public string str{get;set;}
public list<selectoption> country{get;set;}
public void setCountry()
{
country.add(new selectoption(str,str));
}
}
vf page code is :
<apex:page Controller="selectlistoption">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputlabel value="Enter Country"/>
<apex:inputText value="{!str}"/>
<apex:commandButton value="Add" action="{!setCountry}"/>
<apex:commandButton value="submit" rerender="showdetails"/>
</apex:pageBlockSection>
<apex:pageBlockSection id="showdetails">
<apex:selectlist size="1" value="{!str}">
<apex:selectoptions value="{!country}"/>
</apex:selectlist>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
------------------------------------------------------------------------apex code -------------------------------------------------------------
public class selectlistoption {
public string str{get;set;}
public list<selectoption> country{get;set;}
public void setCountry()
{
country.add(new selectoption(str,str));
}
}
you have to create one method. in that you have to add that var into country list.
thn you need to rerender that pageblock section.