function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MenteeMentee 

I am trying to show a popup when picklist is selected along with rendering my components

I am trying to show a popup when picklist is selected but I am unable to do
I tired this https://developer.salesforce.com/forums/?id=906F0000000DDKiIAO
dint work :(

        <apex:outputPanel">
          <apex:outputLabel>Pick one</apex:outputLabel><br/>
          <apex:selectList id="picklst" value="{!selectedValue}" size="1" required="TRUE" multiselect="FALSE">
              <apex:selectOptions value="{!Lst}"/>
              <apex:actionSupport event="onchange" action="{!func}"/>
          </apex:selectList>
        </apex:outputPanel>

I mean it works but doesn't execute <apex:actionSupport event="onchange" action="{!func}"/> as this render the VF components to display form page. I want to display a popup when someone change to value1 to value2. saying data will be lost. Any ideas
Abhishek BansalAbhishek Bansal
Hi Sudha,

You should try with the following code:
//Include scrip tag in your code:
<script>
    function openPopup() {
        window.confirm('You are changing the picklist value');
        return false;
    }
</script>

//In your component you should call this function as:
<apex:outputPanel">
          <apex:outputLabel>Pick one</apex:outputLabel><br/>
          <apex:selectList id="picklst" value="{!selectedValue}" size="1" required="TRUE" multiselect="FALSE" onchange="openPopup()">
              <apex:selectOptions value="{!Lst}"/>
          </apex:selectList>
        </apex:outputPanel>
Please let me know if this doesn't work for you.

Thanks,
Abhishek Bansal.