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
Dhananjaya BulugahamulleDhananjaya Bulugahamulle 

How to give a alert when we select a specific value from pick list?

User-added image
I have a pick list called System Size(System_Size_SUB_2013__c). When I select 2000L SUB from pick list, I want to give an alert to the user. (Only for a 2000L SUB, Not all of them). Any idea how to do that? Thanks

Field
<apex:inputField value="{!Product_Brief__c.System_Size_SUB_2013__c}" required="true"/>

 
Pramodh KumarPramodh Kumar
this can be done using the javascript. We can write in many different ways for this like onchange event or write function if it is equal to the 2000L SUB then through the alert message.
Ajay K DubediAjay K Dubedi
Hello,
Try something like this
<apex:page standardController="Account">
<apex:form >
<apex:inputField value="{!Account.Ownership}" onchange="alert(1);">
</apex:inputField>
</apex:form> 
</apex:page>


Select it as best if it helped you.
Thanks.
Biswa RayBiswa Ray
Hi Dhananjaya,

You can achieve it by invoking a simple JavaScript function on "OnChange" event of Picklist field. 

Code Example,

<apex:page standardController="Account">    
    <script type="text/javascript">        
        function showAccountType(value){          
             alert(value);  //should get the passed value in a alert here.  
        }
        
    </script>
    <apex:form id="form1">
        <apex:pageBlock id="pgid">
            <apex:inputField id= "typeId" value="{!account.type}" onchange="showAccountType(this.value);"/>            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Hope it helps.

Cheers,
Biswa
Dhananjaya BulugahamulleDhananjaya Bulugahamulle
Thanks Guys