DoNNie_DarkO
DoNNie_DarkO

Reputation: 367

enabling a dropdownlist on the selected value of another dropdownlist using Javascript

I have two ASP.NET dropdownlists on my web page.The second one is disabled by default. Can anyone of you guide me to a javascript code which will enable the second dropdownlist when the selected index in the first one is "4", a clientside trigger ofcourse but i cant seem to figure it out.

I have tried the following:

function ddlstClick() { if (document.getElementById("<%=ddlst_ParameterType.ClientID %>").selectedindex = "4") { ddlst_pulldownParameters.Enabled = true; }

Upvotes: 0

Views: 796

Answers (2)

sp_m
sp_m

Reputation: 2707

Try This One.

var e = document.getElementById("<%=ddlst_ParameterType.ClientID %>");
    var strUser = e.options[e.selectedIndex].value;


   if (strUser == "4")
    {
     var x=document.getElementById("<%=seconddropdown.ClientID %>");
        x.disabled=false;
    }

Upvotes: 1

huMpty duMpty
huMpty duMpty

Reputation: 14470

I think you can do something similar if you like to use JQuery

var value = $("#ddlst_ParameterTypeoption:selected").text();
 if (value == "4")
   $("#ddlst_pulldownParameters").attr('disabled', false);

Upvotes: 0

Related Questions