+ Start a Discussion
Ronan O'Neill 6Ronan 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>

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;
Narsimulu ChiranjiNarsimulu Chiranji

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>
Ronan O'Neill 6Ronan O'Neill 6

Thanks for the reply. If its a javascript funciton I want to call what way would I do it?

Ronan O'Neill 6Ronan O'Neill 6
Ok, so it now seems to be calling the function for me using below.

<apex:selectList value="{!dist}" size="1">
          <apex:selectOptions value="{!distList}" ></apex:selectOptions>
         <apex:actionSupport event="onchange" oncomplete="initialize();" reRender="Form"/>

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.