I have picklist values, when change the picklist value need to refresh the page and to populate the picklist value in url using visualforce page.can anybody help me this.

        <apex:selectList size="1" value="{!testvalues}">
                <apex:selectOptions value="{!values}"/>


public class testpage{

    public String testvalues{get; set;}

    public List<SelectOption> getvalues() {
        List<SelectOption> options = new List<SelectOption>();
        List<TESTOBJECT__c> testlist = new List<TESTOBJECT__c>();
        testlist = [Select Id,Name FROM TESTOBJECT__c WHERE  pickvalue=:picklistvalues];
        options.add(new SelectOption('none','none'));
            for (Integer i=0;i<testlist.size();i++)
                options.add(new SelectOption(testlist[i].Name,testlist[i].Name));
            return options;

  • can you pls share your code, what you have tried so far?
    – Ratan Paul
    Mar 14, 2016 at 6:16
  • @Ratan I updated my code,can you see my code.
    – user
    Mar 14, 2016 at 6:44

1 Answer 1


I believe the following is what you need:


    <apex:selectList size="1" value="{!testvalues}">
       <apex:actionsupport event="onchange" action="{!updateUrl}" />
       <apex:selectOptions value="{!values}"/>


public PageReference updateUrl(){
   PageReference pageRef = ApexPages.currentPage();
   pageRef.getParameters().put('paramToUpdate', testvalues);
   return pageRef;

Going further, if you need to see the updated parameters in the URL after the page has refreshed you may need to use:


The above will though "reset" the page and you may need to reload data in the page based on the parameters you provide in the URL.

Optionally, you could use the rerender attribute on the apex:actionsupport tag to rerender an output panel, such as:

<apex:actionsupport event="onchange" action="{!updateUrl}" rerender="myPanel" />

<apex:outputpanel id="myPanel" layout="block">


See the documentation at Salesforce for further information on the apex:actionsupport tag:


Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.