如何在经典ASP/Javascript中从SQL数据库填充2 DropDownMenu [英] How to Populate 2 DropDownMenu from SQL Database in Classic ASP/Javascript

查看:112
本文介绍了如何在经典ASP/Javascript中从SQL数据库填充2 DropDownMenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在尝试找出如何从第一个DropDownMenu上的选择中ping我的第二个DropDownMenu时遇到问题.两者都是从SQL数据库填充的,两行的记录都相似.

exe:

表tblABC

系统
====
AAA
CCC
AAA
AAA
AAA
XXX
CCC
XXX

类型
====
12345
23333
23333
23333
23333
12345
44444
44444

因此,在站点中,用户需要选择一个系统,然后需要根据将具有该选择的系统的选择来选择类型.



第一个下拉菜单=系统AAA

第二个下拉菜单将显示所有类型的系统AAA
可能是
12345
23333
等等
用户将单击该类型选择,然后将基于该类型显示该选择的所有列.

exe:

用户选择:
系统:AAA/类型:12345/组:CCCCCCCCC/说明:Bla Bla Bla


我还想指出,表中的组"行也具有重复的记录...与系统"和类型"相同.

我希望这可以解释一下我的情况...谢谢大家的帮助.

Hi guys,

I''m having problems trying to figure out how to ping point my second DropDownMenu from a selection on the first DropDownMenu. Both are populated from a SQL Database with similar records for both rows.

Exe:

Table tblABC

Systems
====
AAA
CCC
AAA
AAA
AAA
XXX
CCC
XXX

Types
====
12345
23333
23333
23333
23333
12345
44444
44444

so in the site the user needs to select a System then needs to Select a Type based by the selection of the System that will have that selection.

Exe.

first dropdownmenu = System AAA

second dropdownmenu will display all the types of System AAA
that could be
12345
23333
and so on
the user will click on that type selection and based on that it will display all columns for that selection.

Exe:

User selection:
System: AAA / Type: 12345 / Group: CCCCCCCCC / Description: Bla Bla Bla


I also want to point out that Group row in tables have repetitive records as well... same with Systems and Type.

I hope this explains a bit my situation... Thanks all for your help

推荐答案

我可能会像平常一样填充第一个下拉列表. (Gawd,让我看看我是否记得Classic ASP)

像这样的东西:
I''d probably populate the first drop down as you would normally. (Gawd, let me see if I remember by Classic ASP)

Something like:
<%
Response.Write("<SELECT id=''ddParent'' onchange=''populateSecondDropDown();''>")
Response.Write("<OPTION>" & Row("system_id") & "''</OPTION>")
Response.Write("</SELECT>")
%>



然后,我将子项列表写入某种将父项与子项相关联的JavaScript结构:

(请注意,这是伪代码JavaScript.此处不做任何保证!)



Then I would write the list of the child items to some sort of JavaScript structure that associated the parent with the child:

(Note, this is pseudo-code JavaScript. No guarantees are made here!)

<SCRIPT>
var childItems = <%

''Loop through the RecordSet that contains child and parent records

%>;
</SCRIPT>



这样结果将以JSON格式显示如下:



so that the result would look something like this in JSON format:

var childItems = {"System AAA": {"12345", "23333"}};



最后,我将在父下拉菜单populateSecondDropDown()中编写与更改相关的函数.



Finally, I''d write the function associated with the change in the parent dropdown populateSecondDropDown().

<SCRIPT>
function populateSecondDropDown(){
var dropDown = document.getElementById("ddParent");

//clear out elements
dropDown.innerHtml = "";

//populate the dropDown variable with new options from the childItems structure variable.

}
</SCRIPT>


这篇关于如何在经典ASP/Javascript中从SQL数据库填充2 DropDownMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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