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

复选框的动态数据查询,有人遇到过吗,帮忙解决下,谢谢!
jsp页面:四个复选框,每个后面都有一个文本框,单击复选框以后,就可以得到TEXT中的内容,在action中接收,动态地选择所传过来的值通过SQL进行查询,可是我写的查询语句不知道哪里有问题,查不出来结果。有懂case   when语句的帮忙看一下SQL有什么问题,谢谢了
<script   type= "javascript ">
  function   oc1(){
      document.myform.check1.value=document.myform.t1.value;
  }
    function   oc2(){
      document.myform.check2.value=document.myform.t2.value;
  }
    function   oc3(){
      document.myform.check3.value=document.myform.t3.value;
  }
    function   oc4(){
      document.myform.check4.value=document.myform.t4.value;
  }
</script>
<form   method= "post "   action= "ts.do "   name= "myform ">
<br> <br>

<input     type= "checkbox "   name= "check1 "   value= " "   onclick= "oc1() "/>
<input     type= "text "   name= "t1 "   value= " "/>
<input     type= "checkbox "   name= "check2 "   value= " "   onclick= "oc2() "/>
<input     type= "text "   name= "t2 "   value= " "/>
<input     type= "checkbox "   name= "check3 "   value= " "   onclick= "oc3() "/>
<input     type= "text "   name= "t3 "   value= " "/>
<input     type= "checkbox "   name= "check4 "   value= " "   onclick= "oc4() "/>
<input     type= "text "   name= "t4 "   value= " "/>

<input   type= "submit "   name= "Submit "   value= "Submit ">
<input   type= "reset "   value= "Reset ">
</form>
ACTION中接收页面过来的值

//页面接收过来的复选框

                String   v1   =   request.getParameter( "check1 ");
                String   v2   =   request.getParameter( "check2 ");
                String   v3   =   request.getParameter( "check3 ");
                String   v4   =   request.getParameter( "check4 ");

//通过复选框进行动态查询


                try   {
                        Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
                        String   url   =
                                        "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=stu ";
                        Connection   conn   =   DriverManager.getConnection(url,   "sa ",   "1234 ");
            &nb