I have a picklist called type__c on the visual force edit page.

I need the value of what user has chosen on my url.

Following is the code I am using to get the value.

if({!opp.Type__c == "one"}){
                       baseURL = baseURL + "&Type=Temp";
else if({!opp.Type__c == "Two"}){
                       baseURL = baseURL + "&Type=Perm";

Above code does store the value after I click on save. I mean if that opportunity already have the Type__c selected as ONE by default I get type = temp. but when I change type to TWO it does not return Type = Perm .I than have to save and click on edit again in order for that to pass Type = Perm .

I have tried refreshing form Onchage of picklist value but that doesn't help either.

Any suggestions?

1 Answer 1


You're merging in the value, so an onchange won't exactly help you, unless you also rerender the script, like this:

<apex:outputText id="myScript">
    if({!opp.Type__c=='one'}) {

You can then assign an apex:actionSupport to your picklist:

<apex:inputField value="{!opp.Type__c}">
    <apex:actionSupport event="onselect" reRender="myScript" />

This will cause the script to be updated with the new values when the picklist changes.

Personally, I'd rather do this in JavaScript to avoid the hassle of a round-trip to the server, which may cost many hundreds of millseconds instead of the one millisecond (or so) it takes to query it locally:

var oppTypeField = document.getElementById('{!$Component.form.block.oppType}');
var oppType = oppTypeField.options[oppTypeField.selectedIndex].value;
if(oppType == 'one') {
  • I appreciate your help @sfdcfox that helped me solving my problem .
    – Ricky
    Commented Oct 22, 2015 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .