You need to sign in to do that
Don't have an account?
Ronan O'Neill 6
I want to update the value of a selectList on change and reload the page with this value automatically?
Hey, I have a selectList on a page which ties to a String value. I want the value to be updated, the page to reload using this value for a calculation and the selectList to display this value as the current one. I'd like it to happen on change of the value unless a button is required. Any help would be appreciated.
I had tried some javascript to reload the page thinking the value would be automically passed but not finding that to be the case.
My selectList
<apex:selectList value="{!dist}" onchange="document.location.reload(true);" size="1">
<apex:selectOptions value="{!distList}" ></apex:selectOptions>
</apex:selectList>
My Controller
public static String dist {get;set;}
public static List<SelectOption> getdistList() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('25','25km'));
options.add(new SelectOption('50','50km'));
options.add(new SelectOption('100','100km'));
return options;
}
I had tried some javascript to reload the page thinking the value would be automically passed but not finding that to be the case.
My selectList
<apex:selectList value="{!dist}" onchange="document.location.reload(true);" size="1">
<apex:selectOptions value="{!distList}" ></apex:selectOptions>
</apex:selectList>
My Controller
public static String dist {get;set;}
public static List<SelectOption> getdistList() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('25','25km'));
options.add(new SelectOption('50','50km'));
options.add(new SelectOption('100','100km'));
return options;
}
I think this will help you .
In place {!yourMethod} write your method name in which you are doing some operation after changing option values .
<apex:pageBlockSectionItem >
<apex:selectList id="someid" size="1" value="{!dist}" multiselect="false">
<apex:selectOption itemValue="none" itemLabel="--None--"/>
<apex:SelectOptions value="{!distList}"/>
<apex:actionSupport event="onchange" action="{!YourMethod}" reRender="Form"/> </apex:selectList>
</apex:pageBlockSectionItem>
Thanks for the reply. If its a javascript funciton I want to call what way would I do it?
<apex:selectList value="{!dist}" size="1">
<apex:selectOptions value="{!distList}" ></apex:selectOptions>
<apex:actionSupport event="onchange" oncomplete="initialize();" reRender="Form"/>
</apex:selectList>
But the value of
public static String dist {get;set;}
in my controller remains null.
How do I get the value to update to the selected value? It seems like the only thing you would ever want to do with a select List but I can't find the info anywhere.