如何根据Classic ASP中的其他下拉值将值加载到下拉列表中? [英] How to load values into dropdown depending on other dropdown value in Classic ASP?

查看:69
本文介绍了如何根据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[^]


这篇关于如何根据Classic ASP中的其他下拉值将值加载到下拉列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆