当前位置: 代码迷 >> Java Web开发 >> jsp的变量作用域,该如何处理
  详细解决方案

jsp的变量作用域,该如何处理

热度:297   发布时间:2016-04-17 16:08:07.0
jsp的变量作用域
下面是动态生成列表,class表包括字段
        编号,大类,小类
如     1,电脑,联想

这是asp文件
<%@LANGUAGE= "VBSCRIPT "   CODEPAGE= "936 "%>
<!--#include   file= "../Include/conn.asp "   -->
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
<body>
<%  
dim   count
strsql= "select   *   from   class   order   by   大类,小类 "
set   rst=con.execute(strsql)
  %>
<script   language= "JavaScript ">
var   total;
subcat=new   array();
<%   count=0  
do   while   not   rst.eof     %>
subcat[ <%   =count   %> ]=new   array( " <%   =rst(1)   %> ", " <%   =rst(2)   %> ");
<%   count=count+1
rst.movenext
loop  
rst.close   %>
total= <%   =count   %> ;
function   changes(ee)
{ alert( 'a   '   +   window.total);
alert( 'a   '   +   ee);
document.myform.nd2.lenght=0;
alert( 'b   '   +   total);
}
changes( "ee ")
</script>
<form   action= " "   method= "post "   name= "myform "   id= "myform ">
    <table   width= "200 "   border= "0 "   align= "center ">
        <tr>
            <td> 大类 </td>
            <td> <%   rst.open   "select   distinct   大类   from   class   order   by   大类 ",con,1,1
if   rst.eof   then
response.write   "请先添加大类。 "
response.end
else   %>
                <select   name= "st1 "   onchange= "changes(this.value) ">
                    <option   selected   value= " <%   =rst(0)   %> ">
                    <%   =rst(0)   %>
                    </option>
                    <%  
nd2v=rst(0)
rst.movenext  
do   while   not   rst.eof   %>
                    <option   value= " <%   =rst(0)   %> ">
                    <%   =rst(0)   %>
                    </option>
                    <%   rst.movenext
loop
end   if
rst.close   %>
                </select>
  相关解决方案