1

I have a drop-down like this:

<asp:DropDownList ID="cboJPRem" class="jprem" runat="server">
     <asp:ListItem Value="None" Selected="True" Text="None"></asp:ListItem>
     <asp:ListItem Value="1day" Text="1 day"></asp:ListItem> 
</asp:DropDownList>

This drop-down gets disabled and enabled based on value of field 'check A'. If check A is 'T', drop-down will be enabled, if check A is 'F' drop-down will be disabled.

My requirement is to give an alert message(To enable this drop down, change the value of 'check A') when user clicks on disabled drop-down.

$(document).ready(function() {
            $("#cboJPRem").change(function(){
                if($("#cboJPRem:selected").attr("id") == "cboXyz"){
                    alert("To enable this drop down, change the value of 'check A'");
                }
            });

        });

Above code is my attempt to add alert but it is not working. Is there any way to do this?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Divya
  • 9
  • 1
  • 6

1 Answers1

1

Check comments on code:)

$("#cboJPRem").on('change', function() {

    //this will help you to retrive the selected value. 
    var yourVal = $('option:selected', this).attr("id"); 

    //confirm if value is retrived properly
    console.log(yourVal);

    if(yourVal == "cboXyz") {
        //do your stuff
    }
});
Arsee
  • 283
  • 5
  • 20