Click here to Skip to main content
15,914,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a drop down which on selection of one value it is showing another drop down but how can i display something from the selection of value in second drop down.

Here is example and my code is similar to this.

http://jsfiddle.net/JSyLV/1/

thanks in advance
Posted
Updated 11-Apr-12 9:13am
v3
Comments
ZurdoDev 11-Apr-12 14:07pm    
added link
ZurdoDev 11-Apr-12 14:07pm    
Please explain better. What do you want to have happen specifically?
anildhana143 11-Apr-12 14:16pm    
if you see in that example it is showing content when we select an option like that in my example if i select an option from first drop down it is showing one more drop down at bottom and in second drop down if i select an option i need to display content.
on selection of value in first drop down i need to show one more drop down(which is working for me) but on selection in second one i need to show content.
Hope i am clear !!!!!!!!!!
Thanks for reply and highlight link.......
ZurdoDev 11-Apr-12 14:21pm    
No, it isn't clear. Your sample only has one dropdown but you say on selection of second one you need to show content. You already have the code for getting the value of a dropdown and for showing and hiding things so I am having a hard time following what the issue is.
[no name] 11-Apr-12 14:20pm    
Post any relevant code, properly formatted, with your question. Many people won't, or can't, view external sites just to understand your question.

1 solution

Here is an Example, Hope it is exactly what you need...

DropDownList1 Has Collection:
Uttar Pradesh
Delhi
Rajasthan

Now User will select any one of above 3 Items

C#
if (DropDownList1.SelectedItem.Text == "Uttar Pradesh")
      {
          if (DropDownList2.Items.Count > 0)
          {
              DropDownList2.Items.Clear();
          }
          DropDownList2.Items.Add("Kanpur");
          DropDownList2.Items.Add("Allahabad");
          DropDownList2.Items.Add("Banaras");
      
      }
      else if (DropDownList1.SelectedItem.Text == "Delhi")
      {
          if (DropDownList2.Items.Count > 0)
          {
              DropDownList2.Items.Clear();
          }
          DropDownList2.Items.Add("New Delhi");
          DropDownList2.Items.Add("Old Delhi");


      }
      else if (DropDownList1.SelectedItem.Text == "Rajasthan")
      {
          if (DropDownList2.Items.Count > 0)
          {
              DropDownList2.Items.Clear();
          }
          DropDownList2.Items.Add("Jaipur");
          DropDownList2.Items.Add("Ajmer");


      }
 
Share this answer
 
Comments
[no name] 11-Apr-12 15:55pm    
Completely incorrect. The OP was looking for client-side and you gave him server side code. Your example isn't even relevant to the question asked.
anildhana143 11-Apr-12 17:00pm    
Hi,

sorry for all those confusion I created for you......

Hoping I am going to clear all this
<script type="text/javascript">
$(document).ready(function () {
$('.group').hide();
$('#selectMe').change(function () {
$('.group').hide();
$('#' +$(this).val()).show();
})
});
</script>
</head>
<body>
<label for="hi" title="hi">hi</label>
<select name="selectMe" id="selectMe">
<option>Select</option>
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
</select>
<div id="option1" class="group">
<label for="Your State" title="Your State">Your State</label>
<select name="Your State" id="Your State">
<option>Select</option>
<option value="albama">Albama</option>
<option value="alaska">Alaska</option>
<option value="arizona">Arizona</option>
</select>
</div>
<div id="option2" class="group">xxxx</div>
<div id="option3" class="group">vvvv</div>
<div id="option4" class="group">dddd</div>

here is code and if i am user
on page it will show hi"select me" drop down and it has values option1, option2 and option3 when i click on option1--Your state dropdown
option2--XXXX
option3--VVVV
option4--dddd will display to bottom of it.
Now when i click option1 it is showing Your state drop down(My exact question is here) when i click on Your state options(albama,alaska,arizona)it needs to displays content "Hi friends"(if i select arizona).
Hope i am clear now and sorry once again!!!!!!!!!!!
anildhana143 12-Apr-12 13:54pm    
Hi,

Never mind got it

thanks for everything

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900