473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Show and Hide Input Based on Condition

parshupooja
159 100+
Hello,

I am using ASP.NET C#
I have form with several fields on it includes, dropdown and text boxes.
If user selects value 10,20,30, 40, 50, 60 from dropdown1 than textbox2 should get visible othewise it should be invisible. I have more than 2 dropdowns and many text boxes.

Please help
Aug 20 '07 #1
2 1247
nateraaaa
663 Expert 512MB
Hello,

I am using ASP.NET C#
I have form with several fields on it includes, dropdown and text boxes.
If user selects value 10,20,30, 40, 50, 60 from dropdown1 than textbox2 should get visible othewise it should be invisible. I have more than 2 dropdowns and many text boxes.

Please help
I would recommend using a switch case statement and assign the visibility of the text box based on the case. Try this

Expand|Select|Wrap|Line Numbers
  1. switch(dropdown1.SelectedValue)
  2. {
  3. case 10:
  4. case 20:
  5. case 30:
  6. case 40:
  7. case 50:
  8. case 60:
  9.    textbox2.Visible = true;
  10.    break;
  11. default:
  12.     textbox2.Visible = false;
  13.    break;
  14. }
Nathan
Aug 20 '07 #2
parshupooja
159 100+
Thank You it worked, just needed to add " "
Expand|Select|Wrap|Line Numbers
  1. switch(dropdown1.SelectedValue)
  2. {
  3. case "10":
  4. case "20":
  5. case "30":
  6. case "40":
  7. case "50":
  8. case "60":
  9.    textbox2.Visible = true;
  10.    break;
  11. default:
  12.     textbox2.Visible = false;
  13.    break;
  14. }
  15.  
  16.  
Aug 20 '07 #3

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

Similar topics

6
by: Steve Speirs | last post by:
Hi I'm trying to show/hide a simple piece of text and a text field on a form based on what choice is made from a drop down box. <select name="dropdown" size="1"> <option selected...
9
by: sergio | last post by:
Hi all, I have created the following script that will show/hide a menu based on checkboxes. It works fine in Opera but not on IE6! Does anybody knows a workaround this problem? Thanks for your...
5
by: Ray | last post by:
Hi, I was wondering if anyone has any idea how this can be done. I am trying to show/hide navigation links based on server names or ip addresses. So if, someone visits a particular url/ip address...
11
by: jimstruckster | last post by:
I have a table with 10 rows, I want all rows except for the first to be hidden when the page first opens up. If the user puts a value in a text box in the first row then I want the second row to...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
1
by: asilverpeach | last post by:
Hey Guys! Found some great scripts here on this topic but have to make to changes to the code that I can't seem to figure out. First, In the following code clicking on the headers shows the...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
1
by: nithingujjar | last post by:
Hi, I need to to hide a field"addr_state1" based on a value in the drop down list field called "addr_country".i.e.,if addr_country.value=="in" then hide addr_state1 else , and if the value in the...
1
by: filch | last post by:
Hi, I am new to this forum ... so hello to all! I am trying to get a script working which will show or hide a table based on a user checking or unchecking a parent checkbox. This is the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.