有二级关联菜单代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,port.ConnectionFactory" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
function Cha_Select(){
var a1 = new Array("A1","A2","A3")  //可以先从数据库中写到这里
var a2 = new Array("B1","B2","B3")
var a3=  new Array()
var temp1 = document.all("s1")
var temp2 = document.all("s2")
if(temp1.options[temp1.selectedIndex].value!=0)
var temp = eval("a"+temp1.options[temp1.selectedIndex].value)
if(temp!=null){
for(i=0;i<temp.length;i++){
temp2.options[i]=new Option(temp[i],temp[i])
}
}
else{
while(temp2.length>0){
temp2.options[0]=null
}
}
}
</script>
</head>

<body>
<form name="form1" method="post" action="">
<select id="s1" onchange="Cha_Select()">
<option value="">请选择</option>
<option value="1">AAAA</option>
<option value="2">BBBB</option>
<option value="3">CCCC</option>
</select>
<select id="s2">
</select>
&nbsp;&nbsp;&nbsp;
<input type="submit" name="Submit" value="查  询">
</form>
</body>
</html>
<script>中定义的a1,a2的值“可以先从数据库中写到这里”,该怎样从数据库中取出来“写到这里”?