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

向js数组里赋值为什么不成功?
<script   language= "javascript ">
var   kmArray=new   Array();
var   kmxx=   new   Array();
var   stArray=new   Array();
var   stxx   =   new   Array();  
<%  
CachedRowSet   kmdmRowSet=null;
kmdmRowSet=manage_Sjgl.GetKmdmList();
//int   kmnum=kmdmRowSet.size();
String   kmdm=null;
String   kmxx=null;
int   m=0;
while(kmdmRowSet.next()){
      kmdm=kmdmRowSet.getString( "kmdm ");
      kmxx=kmdm+ "   "+kmdmRowSet.getString( "kmmc ");  
%>
      kmArray[ <%=m%> ]= " <%=kmdm%> ";
      kmxx[ <%=m%> ]= " <%=kmxx%> ";
   
<%
CachedRowSet   strs=untilBean.getStListManyOptions(kmdm);
//int   stnum=strs.size();
String   stxh=null;
String   stxx=null;
int   s=0;
while(strs.next()){

        stxh=strs.getString( "stxh ");
stxx=stxh+ "   "+strs.getString( "stmc ");
%>

        stArray[ <%=m%> ][ <%=s%> ]= " <%=stxh%> ";
stxx[ <%=m%> ][ <%=s%> ]= " <%=stxx%> ";

<%
s++;
}
        m++;
}
%>
</script>
经过我的检测发现kmxx中只有一个值,不知道为什么,谁能来救命?

------解决方案--------------------
感觉有点复杂.能不能用中文描述一下呢
------解决方案--------------------
while(kmdmRowSet.next()){
kmdm=kmdmRowSet.getString( "kmdm ");
kmxx=kmdm+ " "+kmdmRowSet.getString( "kmmc ");

out.println( "kmArray[ "+m+ "]=\ " "+kmdm+ "\ "; ");
out.println( "kmxx[ "+m+ "]=\ " "+kmxx+ "\ "; ");

CachedRowSet strs=untilBean.getStListManyOptions(kmdm);
//int stnum=strs.size();
String stxh=null;
String stxx=null;
int s=0;
while(strs.next()){

stxh=strs.getString( "stxh ");
stxx=stxh+ " "+strs.getString( "stmc ");

out.println( "stArray[ "+m+ "]=new Array(); ");
out.println( "stxx[ "+m+ "]=new Array(); ");

out.println( "stArray[ "+m+ "][ "+s+ "]=\ " "+stxh+ "\ "; ");
out.println( "stxx[ "+m+ "][ "+s+ "]=\ " "+stxx+ "\ "; ");


s++;
}
m++;
}