This is version of type 1
I'll answer your last Question seperately
database has two tables
table1 and table2
Code:
table1:
id list1
1 boys names
2 girls names
table2:
id list2
1 Bert
1 fred
1 Joe
1 Mark
1 Tim
2 Betty
2 Dot
2 Mary
2 Sally
and the script:
Code:
<%@ Language=VBScript %>
<BODY BACKGROUND="rfbg.gif" BGCOLOR="#ffffff">
<HEAD>
<!--
Written by Mark Sreeves
-->
<%
'now load all the data for list 2 from table2 into the client side javascript array
dim conn
dim rst
Set Conn = Server.CreateObject("ADODB.Connection")
strSQL = "SELECT * FROM table2;"
Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\lenin.mdb")
Set rst = Conn.Execute(strSQL)
Response.Write("<script Language='JavaScript'>" & vbcrlf)
Response.Write("var DetailArray = new Array();")
i = 0
do while not rst.EOF
%>
DetailArray[<%=i%>]= new Array("<%=rst("id")%>","<%=rst("List2")%>");
<%
rst.MoveNext
i = i + 1
loop
rst.Close
Response.Write("</script>")
%>
<script Language="JavaScript">
var i;
function fillList2(id){
var j;
j = 1;
for(var i=0; i < DetailArray.length; i++)
{
if (DetailArray[i][0] == id)
{
document.frm1.select2.options[j].value =j;
document.frm1.select2.options[j].text = DetailArray[i][1];
j++;
};
}
}
</script>
<form name="frm1">
<SELECT name=select1 onchange="fillList2(select1.options[select1.selectedIndex].value)">
<%
strSQL = "SELECT * FROM table1;"
Set rst = Conn.Execute(strSQL)
do while not rst.EOF
'fill the combo box
%>
<OPTION value="<%=rst("id")%>"><%=rst("list1")%>
<%rst.MoveNext
loop
rst.close
conn.Close
set conn = nothing
set rst = nothing
%>
</SELECT>
<BR>
<SELECT name=select2>
<% 'load dummy options
for i = 0 to 10
Response.Write "<OPTION value='xx'>"
next
%>
</SELECT>
</form>
</BODY>
</HTML>