javascript to either enable or disable the dropdown

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
 
B

bruce barker

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)
 
Z

zlf

"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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top