By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,909 Members | 2,008 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,909 IT Pros & Developers. It's quick & easy.

Dynamically enable/disable controls on dropdown selectedindex change

abehm
P: 35
Hey all,
I'm trying to disable a couple controls if a user clicks on a certain item in a dropdown list. I can do it on postback, but if someone could help me to do it dynamically, that would be key! Thanks in advance!
Aaron
Jul 24 '07 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
Hey all,
I'm trying to disable a couple controls if a user clicks on a certain item in a dropdown list. I can do it on postback, but if someone could help me to do it dynamically, that would be key! Thanks in advance!
Aaron
Call a Javascript function onChange of the dropdown and you're done! The function that you call will simply disable the items based on the value selected in the drop down.
Jul 24 '07 #2

pbmods
Expert 5K+
P: 5,821
Merged duplicate threads.
Jul 24 '07 #3

abehm
P: 35
yeah, i understand that's what I have to do. I just don't know if this function will work:
Expand|Select|Wrap|Line Numbers
  1.  
  2. function IsSelected()
  3. {
  4.     if ((cboParameters.SelectedItem.Text == "All Passed Tests") || (cboParameters.SelectedItem.Text == "All Failed Tests")
  5.             || (cboParameters.SelectedItem.Text == "All Incomplete Tests") || (cboParameters.SelectedItem.Text == "All Complete Tests"))
  6.     {
  7.         cboOperators.Visible = false;
  8.         txtComparisonValue.Visible = false;
  9.         lblMessage.Text = "";
  10.     }
  11.     else
  12.     {
  13.         cboOperators.Visible = true;
  14.         txtComparisonValue.Visible = true;
  15.     }
  16. }
  17.  
also, this is in an asp page, not html.
Jul 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.