javascript to either enable or disable the dropdown

  • Thread starter Thread starter zlf
  • Start date Start date
Z

zlf

I need a javascript to either enable or disable the dropdowns when the user
clicks on the checkbox and do NOT post back to the server.
I tried the following, but it does not work. How to correct it?

AssignToQueueCheckBox.Attributes["oncheckedchanged"] =
"document.getElementById('ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$WorkUnitDropDownList').disable=!document.getElementById('ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$WorkUnitDropDownList').disable;"
+


Thanks

zlf
 
as there is no "oncheckedchanged" event for a checkbox, you are just defining
a custom attribute. try: "onclick"

also it really a bad practice to view source to get the control names, you
shouald ask the control for is ClientID:

-- bruce (sqlwork.com)
 
"onclick" does not work too :(

bruce barker said:
as there is no "oncheckedchanged" event for a checkbox, you are just
defining
a custom attribute. try: "onclick"

also it really a bad practice to view source to get the control names, you
shouald ask the control for is ClientID:

-- bruce (sqlwork.com)


zlf said:
I need a javascript to either enable or disable the dropdowns when the
user
clicks on the checkbox and do NOT post back to the server.
I tried the following, but it does not work. How to correct it?

AssignToQueueCheckBox.Attributes["oncheckedchanged"] =

"document.getElementById('ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$WorkUnitDropDownList').disable=!document.getElementById('ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder2$WorkUnitDropDownList').disable;"
+


Thanks

zlf
 
Back
Top