Cansler
asked on
Using Javascript to disable asp dropdownlist
Check this problem out:
I have two asp:dropdownlist controls on a page. If you select option 3 in the first drop down, then the second drop down should become disabled. If you select anything other than option 3 in the first drop down, then the second dropdown should be (re)enabled.
It would be nice to do this client-side. Can javascript do this?
I have two asp:dropdownlist controls on a page. If you select option 3 in the first drop down, then the second drop down should become disabled. If you select anything other than option 3 in the first drop down, then the second dropdown should be (re)enabled.
It would be nice to do this client-side. Can javascript do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes. Add it in PageLoad() event.
-Nauman.
-Nauman.
hi,
try
this
'Server Side
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DropDownList1.Attributes(" onchange") = "ChangeDrpDown2()"
End Sub
//Client side java script
function ChangeDrpDown2()
{
if(document.Form1["DropDow nList1"].o ptions.val ue==3)
{
document.Form1["DropDownLi st2"].disa bled=true;
}
else
{
document.Form1["DropDownLi st2"].disa bled=false ;
}
}
regards
pradeep
try
this
'Server Side
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DropDownList1.Attributes("
End Sub
//Client side java script
function ChangeDrpDown2()
{
if(document.Form1["DropDow
{
document.Form1["DropDownLi
}
else
{
document.Form1["DropDownLi
}
}
regards
pradeep
ASKER