我从网上找的、一个用 javascript实现的三级联动的程序,其中连数据库部分被封装了,没有给提供,如果是我引用jsp中的连数据库程序,在javascript中的rs.getString所取内容遇到了无法转换编码的中文问题,哪位高手帮我写下system.pub.oraclesql myDao = new system.pub.oraclesql();用到的system.pub包,并且他应该放在什么位置呢?或者是帮我把关于数据库的rs.getString写在javascript外边,这样就可以转换编码了:
代码如下:
<script language= "javascript ">
var DeparmentCount; //三级联动菜单代码
DeparmentCount = 0;
var DivisionCount;
DivisionCount = 0;
var SpecialityCount;
SpecialityCount = 0
Department = new Array();
Division = new Array();
Speciality = new Array();
<% system.pub.oraclesql myDao = new system.pub.oraclesql();
ResultSet rs = myDao.execQuery( "select * from division ");
int i=0;
for(rs.next();!rs.isAfterLast();rs.next(),i++){%>
Division[ <%=i%> ] = new Array( " <%=rs.getString( "Division_name ")%> ", " <%=rs.getString( "department_id ")%> ");
<% }%>
DivisionCount = <%=i%> ;
<%
System.out.println( "debug....1 ");
rs = myDao.execQuery( "select * from speciality ");
i=0;
for(rs.next();!rs.isAfterLast();rs.next(),i++){%>
Speciality[ <%=i%> ] = new Array( " <%=rs.getString( "Speciality_name ")%> ", " <%=rs.getString( "division_id ")%> "); <% }%>
SpecialityCount = <%=i%> ;
function changeDepartment(DepartmentId){
document.form1.Switch.value= "false ";
document.form1.division.length = 0;
var DepartmentId = DepartmentId;
var i;
for (i=0;i < DivisionCount; i++){
if (Division[i][1] == DepartmentId){
document.form1.division.options[document.form1.division.length] = new Option(Division[i][0], Division[i][0]);
}
}
changeDivision(document.form1.division.value);
}
function changeDivision(DivisionId){
document.form1.Switch.value= "false ";
document.form1.speciality.length = 0;
var DivisionId = DivisionId;
var i;
for (i=0;i < SpecialityCount; i++){
if (Speciality[i][1] == DivisionId){
document.form1.speciality.options[document.form1.speciality.length] = new Option(Speciality[i][0], Speciality[i][0]);