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
mac adminmac admin 

confirmation dialog box while changhing picklist value

Hi all,
In custom vfpage with standard controller, I'm showing different fields based on picklist value selection using actionsupport component with the event as onchnage. I want to show a confirmation box before changing the picklist value. I'm using ready function but it's not working for me can any one help me over here.
<script type="text/javascript">

$(document).ready(function () {

    $(".department").on("change", function () {
        var ddlBrand = $('.department');
        var value = ddlBrand.val();
        var prevValue = ddlBrand.data('prev');

        if ( value != '--Select--' && prevValue && prevValue != '--Select--') {
        
        var confirmval = confirm('Values entered  will reset. Are you sure you want to change the picklist value.');
            if(confirmval == true){
               ddlBrand.data('prev', value) 
            }else{
                ddlBrand.val(prevValue )
            }
        }else{
            ddlBrand.data('prev', value)
        }
    });

});

</script>



Thanks in advance.

Regards,
mac
Lokesh KumarLokesh Kumar
HI Mac,

Please go through this article http://salesforce.stackexchange.com/questions/45579/javascript-alert-on-change-of-picklist-value

Hope it will help you!

Lokesh