User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,634 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,592 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2639 | Replies: 2
Reply
Join Date: Aug 2007
Posts: 2
Reputation: finch is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
finch finch is offline Offline
Newbie Poster

Help dropdownlist disable other dropdownlist

  #1  
Aug 21st, 2007
Hi Guys

I'm a newbie in asp.net and I want to disable dropdownlist1 in my form when value "no" is selected from the <asp:ListItem> of dropdownlist2. How can I achieve that? Thanks for reply. BTW I'm using C# language.

Finch
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,858
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: dropdownlist disable other dropdownlist

  #2  
Aug 21st, 2007
A very simple and crude snippet:
<select name="first" id="first" onchange="if(this.value == 'no') document.getElementById('sec').disabled=true; else document.getElementById('sec').disabled=false;">
    <option value="yes">Yes</option>
    <option value="no">No</option>
</select>
<br /><br />
<select name="sec" id="sec">
    <option value="yes">Yes</option>
    <option value="no">No</option>
</select>

I would leave to you the job of putting those bunch of statements in a separate function and changing the way the function is called as per your requirement.
Last edited by ~s.o.s~ : Aug 21st, 2007 at 11:58 am.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Aug 2007
Posts: 2
Reputation: finch is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
finch finch is offline Offline
Newbie Poster

Re: dropdownlist disable other dropdownlist

  #3  
Aug 21st, 2007
Thank for your help mate.

Problem is that solution is perfect for html form, not asp.net - therefore I cannot use it within <br> and <td> tags in asp form. I also cannot use method onchange, web developer says that it is no supported by dropdownlist. Any ideas how to trick it? Thanks a lot for your time.

Finch

Edit: Here's the code I want to change:

<asp:View ID="View4" runat="server">
<table cellpadding="4" cellspacing="4">
<tr>
<td colspan="2"><b>Section 3 - Health and Safety Policy and Arrangements</b></td>
</tr>
<tr>
<td>3.1 Does your company have a written Health and Safety Policy?</td>
<td><aspropDownList ID="HealthPolicy" runat="server" >
<asp:ListItem></asp:ListItem>
<asp:ListItem>No</asp:ListItem>
<asp:ListItem>Yes</asp:ListItem>
</aspropDownList>
</td>
</tr>
<tr><td>If yes, please provide us with copy of your health and safety policy. Please go to section 3.3. If No, please answer question 3.2</td></tr>
<tr>
<td>3.2 Does your company employ 5 or persons?</td>
<td><aspropDownList ID="Employ5" runat="server" Enabled="False" >
<asp:ListItem></asp:ListItem>
<asp:ListItem>No</asp:ListItem>
<asp:ListItem>Yes</asp:ListItem>
</aspropDownList>
</td>
</tr>
Last edited by finch : Aug 21st, 2007 at 5:46 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 12:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC