You need to sign in to do that
Don't have an account?
Kevin Jackson 11
Trouble getting value from Selected List
Hi I am trying to get that value from a selected list as a variable going to the next VF page. However, it continues to only give me the default value (2):
VF Page
Any help would be appreciated!
VF Page
<apex:page controller="ParameterController"> <h1>Your latest Membership Status</h1> <apex:pageBlock > <apex:pageBlockSection > <apex:form > <p> How Long to extend your ISN membership <apex:selectList size="1" value="{!SelectedValue}" label="SelectedValue" id="SelectedValue"> <b> <apex:selectOptions value="{!dynamiclist}" /></b> <p></p> <apex:actionSupport event="onchange" reRender="one" /> </apex:selectList></p><p></p> </apex:form> <form id="browserpost" method="POST" action="Page2"> <input type="hidden" name="namex" value="{!Contact.Name}"/> <input type="hidden" name="Payment" value="{!SelectedValue*203}"/> <button type="submit" > Make Payment </button> <apex:outputLabel id="one" > You have selected: {!selectedValue} years. The total cost will be: ${!selectedValue*203} </apex:outputLabel> </form><p></p> </apex:pageBlockSection> </apex:pageBlock> </apex:page>Relevant Contoller:
// DROP DOWN LIST FOR YEARS TO RENEW public Integer selectedValue { get { if(selectedValue==null) selectedValue=2; return selectedValue; } set; } public List<SelectOption> getdynamiclist() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('1','1 year')); options.add(new SelectOption('2','2 years')); options.add(new SelectOption('3','3 years')); options.add(new SelectOption('4','4 years')); options.add(new SelectOption('5','5 years')); return options; }
Any help would be appreciated!
public PageReference gotoPage2() {
return Page.Page2
}
All Answers
Please check below code .Why three forms functionality here in the page .
Let me know if it helps .
Thanks
Manoj
bottom line, use the same controller for both VF pages and it will work...
This part works. It rerenders and shows the value that the user chose.
This is the part I am having trouble with. Specifically Payment which should be !SelctedValue (3 in my example) *203.
On the destination VF page I get these variables:
{!$CurrentPage.parameters.Payment}= null
{!selectedValue} = 2 (Which is the default, but it never gives me the selected value. '3' in my test)
{!$CurrentPage.parameters.Namex} = gives me the correct name requested.
It seems that the SelectedValue variable changes its value when it rerenders, but then reverts to the default or null.
Thanks in advance for your help.
Another question, why are you using this constuction to post to Page2 ?
My objective is to simply be able to go to page 2 and pass some variables. Do you have a better way to do it?
public PageReference gotoPage2() {
return Page.Page2
}
THANKS VERY MUCH!