下面少的</script>,补上哦!!

解决方案 »

  1.   

    如果我想用上面test的值传到下面sql语句中该怎么写啊??谢谢各位了!!
      

  2.   

    我晕,看来小丫头你得先弄清楚asp页面究竟是怎样一个执行逻辑
      

  3.   

    真晕倒!!!
    一个在客户端的,一个在服务器端的,怎么合在一起用呢?
    而且ASP是用&连接字符串,也不是用+号连接字符串吧。
      

  4.   

    我也晕~~
    asp是在报务器端执行后,把HTML和javascript代码等传到客户机的
      

  5.   

    我用的是jsp, 哦,原来不可以啊??
      

  6.   

    也不一定要这样,你可以在客户端提交你的SQL查询语句,由服务器解释后生成你要的结果页面,不过JSP里不可以用JS的变量,你要是想用,先提交当前页把JS里的变量转化到JSP里去吧
      

  7.   

    要实现只有提交,或者用XMLHTTP,具体要看你想用那个结果集干什么了,呵呵
      

  8.   

    可以实现的,不知道你说的多选框是什么,先贴上下面的代码,是用下拉列表选择然后改变列表框的值,已经通过测试:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    function conArray(id,text)
    {
    this.id = id;
    this.text = text;
    }
    function getContent()
    {
    var sel1 = document.getElementById("list1");
    var sel2 = document.getElementById("list2");
    sel2.length = 0;  //将列表框的值清空
    for(var i=0;i<a.length;i++)
    {
    //如果值相等,则加入列表框
    if(a[i].id == sel1.value)
    {
    sel2.options[sel2.options.length] = new Option(a[i].text,a[i].id);
    }
    }
    }
    var a = new Array();
    for(var i=0;i<10;i++)
    {
    a[i] = new conArray(i,"这是第" + i + "个数值");
    }
    </script>
    </head><body>
    <form id="form1">
    <select id="list1" onChange="getContent();">
    <option value="1">内容1</option>
    <option value="2">内容2</option>
    <option value="3">内容3</option>
    <option value="4">内容4</option>
    <option value="5">内容5</option>
    </select>
    <br>
    <select multiple id="list2" size="8" style="width:100px">
    </select>
    </form>
    </body>
    </html>
    这些都是在客户端发生的,如果你想结合服务器的,有两种方法,一种就是在页面生成的时候将服务器端的相关数据都发送到客户端js代码的数组中,然后通过多选框中的选择值,确定列表框中需要加在的数据(具体jsp代码你自己纠正):
    定义一个结构:
    function contentArray(id,text) //id就是它们对应的第一级的查询所用的参数,text就是相关内容
    {
      this.id = id;
      this.text = text;
    }
    然后就是它们的数组:
    var a = new Array();
    for(var i=0;i<rs2.recordCount;i++) //recordcount就是记录条数,我不知道jsp怎么写
    {
      a[i] = new contentArray(<%= rs2(id) %>,"<%= rs2(text) %>");//具体字段需要你自己调整
    }
    这样就在客户端的js变量中获得了所有需要的数据,当你的左边多选框的值改变,你就可以用例子的方法到数组a中寻找相应的数据并加入到下拉框。
    第二个方法就是使用frameset,在下面一个页面中查询相应的值。
    第一种方法如果数据多不太合适,会影响客户端性能。
    吃饭去了,呵呵,剩下的再说,类似的帖子csdn很多,你自己搜索一下。
      

  9.   

    多选框就是下拉的列表的那中<select name="a" multiple><option value="aa">aa</select>
    这种的,呵呵~~,先谢谢你了!!
      

  10.   

    第二个方法就是用frameset或者iframe,让他们不可见,当你选择不同的值的时候将值放在url后传递给他们,让他们返回服务器端找到相应的第二级多选框的内容,并加入到二级列表框中。
    这里是一个例子(测试已经通过,只要将相应的java部分写好就能用):
    框架集窗口1.htm
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><frameset rows="*" cols="100%,*" id="fms" name="fms">
      <frame src="main.htm" id="leftFrame" name="leftFrame" scrolling="auto" noresize>
      <frame src="temp.htm" id="rightFrame" name="rightFrame">
    </frameset>
    <noframes></noframes>
    </html>
    左窗口main.htm
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    function getContent()
    {
    top.rightFrame.location.href = "blank.htm";
    }
    </script>
    </head><body>
    <form id="form1">
    <select multiple id="sel1" style="width:100px" size="8" onChange="getContent();">
    <option value="1">内容1</option>
    <option value="2">内容2</option>
    <option value="3">内容3</option>
    <option value="4">内容4</option>
    <option value="5">内容5</option>
    </select>
    <select multiple id="sel2" style="width:100px" size="8"></select>
    </form>
    </body>
    </html>右边的临时窗口temp.htm:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    </body>
    </html>点击后加载内容的窗口blank.htm:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    function conArray(id2,text2)
    {
    this.id2 = id2;
    this.text2 = text2;
    }
    var content = new Array();
    //content[0] = new conArray("1","2");
    //content[1] = new conArray("1","2");
    //content[2] = new conArray("1","2");
    //content[3] = new conArray("1","2");
    //<%
        //这里需要用java取得第二级的内容
    //首先要取得传递过来的值
    //String id1 = request.QueryString("id1");
    //这里用这个id1到数据库中查询相应的值并输入到数组中,假设结果集为rs2
    //%>
    //<%
    //for(int i=0;i<rs2.recordCount;i++)
    //{
    //response.write("content[" + i + "] = new conArray(" + rs2("id2") + "," + rs2("text2") + ");");
    //}
    //%>
    </script>
    <script language="javascript">
    function setValue()
    {
    var sel2 = top.leftFrame.document.getElementById("sel2");
    sel2.options.length = 0;
    for(var i=0;i<content.length;i++)
    {
    sel2.options[i] = new Option(content[i].text2,content[i].id2);
    }
    }
    </script>
    </head><body onLoad="setValue();">
    </body>
    </html>
      

  11.   

    我这个都实现了,我就是想现在提交之后,怎么的到<select multiple>的值啊??
      

  12.   

    在asp中用个for each...next循环啊!
      

  13.   

    在处理页面使用getParameter函数就可以了:
    String a = request.getParameter("sel1"); //sel1为提交过来的那个多选框的名字如果是多选,就用getParameterValues函数:
    String[] a = request.getParameterValues("sel1");
    for(int i=0;i<a.length;i++)
    {
      out.println(a[i]);
    }
      

  14.   

    哦,该结贴了啊!!!我可是从来不也这样子把<%%>里的东东放到Script里啊!!!
      

  15.   

    我用哪个方法接受了,他说是空指针异常java.lang.NullPointerException