根据下拉列表中的值显示的内容 [英] content to display according to values in drop down
本文介绍了根据下拉列表中的值显示的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个下拉列表,其中选择一个值时会显示另一个下拉列表,但是如何从第二个下拉列表中的值选择中显示某些内容.
这是示例,我的代码与此类似.
http://jsfiddle.net/JSyLV/1/
在此先感谢
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
推荐答案
这里是一个示例,希望它正是您所需要的...
DropDownList1有收藏集:
北方邦
德里
拉贾斯坦邦
现在,用户将选择以上3个项目中的任何一个
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
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");
}
这篇关于根据下拉列表中的值显示的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文