如何根据Classic ASP中的其他下拉值将值加载到下拉列表中?
嗨
我是初次接触经典ASP技术的人.
在我的应用程序中,我有一个包含2列的数据库表.
在用户界面中,我有2个下拉菜单.
现在,我想根据第一个下拉列表值将值加载到第二个下拉列表.
考虑我的桌子如下
column1 column2
1 --------一个
2 --------两个
3 --------三
4 --------四
现在,如果我在第一个下拉菜单中选择1,则应该将其中一个加载到第二个下拉菜单.
如果我在第一个下拉菜单中选择2,则应将两个加载到第二个下拉菜单.
如何在Classic ASP中为此编写代码?请帮助
Hi
I am new to work on Classic ASP technology.
In my application I have a database table with 2 columns.
in the UI I have 2 drop downs.
Now I want to load the value to 2nd drop down depending on 1st dropdown value.
consider my table as below
column1 column2
1 -------- one
2 -------- two
3 -------- three
4 -------- four
Now If I select 1 in 1st dropdown one should be loaded to 2nd dropdown.
If I select 2 in 1st dropdown two should be loaded to 2nd dropdown.
How can I write code for this in Classic ASP? Pls help
thanks in advance.
<body>
<form id="form1" runat="server">
<div>
Select Country :<br />
<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged" xmlns:asp="#unknown">
<asp:listitem>-Select-</asp:listitem>
<asp:listitem value="1">India</asp:listitem>
<asp:listitem value="2">Australia</asp:listitem>
</asp:dropdownlist>
<br />
Select State:<br />
<asp:dropdownlist id="DropDownList2" runat="server" xmlns:asp="#unknown">
</asp:dropdownlist>
</div>
</form>
</body>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string[] statelistIndia = new string[] {"-Select-","Maharashtra","New Delhi" };
string[] statelistAus = new string[] { "-Select-", "Victoria", "West Australia" };
if (DropDownList1.SelectedValue=="1")
{
DropDownList2.DataSource = statelistIndia;
DropDownList2.DataBind();
}
if (DropDownList1.SelectedValue == "2")
{
DropDownList2.DataSource = statelistAus;
DropDownList2.DataBind();
}
}
您可以使用javascript来做到这一点.以下是选项和示例:
http://classicasp.aspfaq.com/forms/how-do-i-make-one-dropdown-depend-on-another.html [ http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=126 [ ^ ]
You can do this by using javascript. here are the options and examples:
http://classicasp.aspfaq.com/forms/how-do-i-make-one-dropdown-depend-on-another.html[^]
populate the two dropdowns from the database and using javascript, filter the second dropdown.
Example of populating the database:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=126[^]