日期:2014-05-18  浏览次数:20706 次

javascript中的中文转换问题
我用JSP做的一个三级联动在从数据库查出来的内容需要用.getBytes( "iso-8859-1 "), "gb2312 "转换中文问题,我的程序中的IsoConvertGc就是实现这个功能的,但是我发现这个方法在普通程序中用可以,在javascript中就不起作用,如在这段话中就正确
    <option   value= " <%=IsoConvertGc(rs2.getString( "fenlei "))%> "> <%=IsoConvertGc(rs2.getString( "fenlei "))%> </option> 在javascript中就不可以,哪位高手给我指点指点没,代码如下:
<%!

public   String   IsoConvertGc(String   insert)

{

String   outstr;

try

{

if   (insert   ==   null   ||   insert.trim().length()   ==   0)

{

return   insert;

}

outstr   =   new   String(insert.getBytes( "iso-8859-1 "), "gb2312 ");

}

catch   (Exception   e)

{

outstr   =   null;

}

return   outstr;

}

%>
<body   onload= "initialSelect(); ">
<%   Connection   con;
Statement   stmt;Statement   stmt1;Statement   stmt2;
String   hostName               =   "61.32.251.131 ";

        String   portNumber           =   "1521 ";

        String   databaseSID         =   "ora9i ";  
           
            //数据库登录用户和密码
            String   user= "fhsr ";
            String   password= "iltutilu ";
            Class.forName( "oracle.jdbc.driver.OracleDriver ");
            String   url= "jdbc:oracle:thin:@ "+hostName+ ": "+portNumber+ ": "+databaseSID;

            stmt=con.createStatement();   stmt1=con.createStatement();stmt2=con.createStatement();
    ResultSet   rs   =   stmt.executeQuery( "select   distinct   *   from   division ");
    ResultSet     rs1   =   stmt1.executeQuery( "select   distinct   *   from   speciality ");
    //String   sql   =   "select   *   from   wupinbiao   where   leixing= ' "+leixing+ " '   and   tiaoma= ' "+tiaoma+ " '   and   xinghao= ' "+xinghao+ " '   ";
    %>
    <script   language= "javascript ">
    var   DeparmentCount;   //三级联动菜单代码
    DeparmentCount   =   0;
    var   DivisionCount;
    DivisionCount   =   0;
    var   SpecialityCount;
    SpecialityCount   =   0
    Department   =   new   Array();
    Division   =   new   Array();
    Speciality   =   new   Array();
<%
 
    int   i=0;
    for(rs.next();!rs.isAfterLast();rs.next(),i++){%>
    &nbs