解决办法:
我用ASP做过类似的功能,,第一步:
用JSP把数据库中表的字段得到,,java.sql.* 有实现操作的类,,
<%
for{%>
<input type=checkbox name="colName" value="<%=colName%>"><%=colName%>
<%}%>
第二步
当checkbox被选择时检测有多些checkbox被选,,大于30时,提示,,,
之后提交,,
第三步
接收String array=request.getParameterValues("colName");
String col_sql="";
for(int i=0;i<array.length-1;i++){
  col_sql+=array[i]+",";
}
col_sql+=array[i];sql="select "+col_sql+" form table ....."

解决方案 »

  1.   


    <HTML>
    <HEAD>
    <TITLE>自定义统计表</TITLE>
    <script language="javascript" src="../include/input.js"></script>
    <SCRIPT language=JavaScript><!-- Begin
    sortitems = 1;  // Automatically sort items within lists? (1 or 0)function move(fbox,tbox) {
    for(var i=0; i<fbox.options.length; i++) {
    if(fbox.options[i].selected && fbox.options[i].value != "") {
    //alert (i);
    if (tbox.options.length==0){
    abc(fbox,tbox,i);
    }
    else{
    for(var m=0; m<tbox.options.length; m++) {
    //alert (m);
    //alert (fbox.options[i].text);
    //alert (tbox.options[m].text);
    if (fbox.options[i].value==tbox.options[m].value){
    //alert("kkk");
    return false;
    }
     }
     abc(fbox,tbox,i);
    }
    }
    }
    BumpUp(fbox);
    if (sortitems) SortD(tbox);
    }function abc(fbox,tbox,num)
    {
    var no = new Option();
    no.value = fbox.options[num].value;
    no.text = fbox.options[num].text;
    tbox.options[tbox.options.length] = no;
    }function formsub(){if (window.event.keyCode==13){submit1.click();
    }}function addvaluetext(){
    var str=formviewarea.begintime.value;
    var str1=formviewarea.endtime.value;
    if (document.formviewarea.list2.options.length<1)
       {
    window.setTimeout('alert("不能提交空景区")',50);
    return false;
    }
    if (str==""){
    alert("开始日期不能未空");
    return false;
    }
    if (str1==""){
    alert("结束日期不能未空");
    return false;
    }
    document.formviewarea.hiddentext1.value="";
    document.formviewarea.hiddentext2.value=""; for(var i=0; i<document.formviewarea.list2.options.length; i++)
    {
    if (document.formviewarea.hiddentext1.value==""){
    document.formviewarea.hiddentext1.value=document.formviewarea.list2.options[i].value;
    }
    else{
    document.formviewarea.hiddentext1.value=document.formviewarea.hiddentext1.value+","+document.formviewarea.list2.options[i].value;
    }
    if (document.formviewarea.hiddentext2.value==""){
    document.formviewarea.hiddentext2.value=document.formviewarea.list2.options[i].text;
    }
    else{
    document.formviewarea.hiddentext2.value=document.formviewarea.hiddentext2.value+","+document.formviewarea.list2.options[i].text;
    }
    }
    }
    /*mys:此函数是去掉已选择字段空值,并计算已选择字段列表的长度*/
    function BumpUp(box)  {
    for(var i=0; i<box.options.length; i++) {
    if(box.options[i].value =="")  
    {
    for(var j=i; j<box.options.length-1; j++)  
    {
    box.options[j].value = box.options[j+1].value;
    box.options[j].text = box.options[j+1].text;
    }
    var ln = i;
    break;
    }
    }
    if(ln < box.options.length)  {
    box.options.length -= 1;
    BumpUp(box);
    }
    }/*mys:排序*/
    function SortD(box)  {
    var temp_opts = new Array();
    var temp = new Object();
    for(var i=0; i<box.options.length; i++)  
    {
    temp_opts[i] = box.options[i];
    }
    for(var x=0; x<temp_opts.length-1; x++)  
    {
    for(var y=(x+1); y<temp_opts.length; y++)  
    {
    if(temp_opts[x].text > temp_opts[y].text)  
    {
    temp = temp_opts[x].text;
    temp_opts[x].text = temp_opts[y].text;
    temp_opts[y].text = temp;
    temp = temp_opts[x].value;
    temp_opts[x].value = temp_opts[y].value;
    temp_opts[y].value = temp;
    }
    }
    }
    for(var i=0; i<box.options.length; i++)  {
    box.options[i].value = temp_opts[i].value;
    box.options[i].text = temp_opts[i].text;
    }
    }
    // End -->
    </SCRIPT><SCRIPT language=javascript>
    <!--
    sortitems = 1;
    function delete1(tbox){
    for (var i=0;i<document.formviewarea.list2.options.length;i++){
    if (document.formviewarea.list2.options[i].selected){
    document.formviewarea.list2.options[i].value="";
    document.formviewarea.list2.options[i].text="";
    }
    }
    BumpUp(tbox);
    if (sortitems) SortD(tbox);
    }
    //-->
    </SCRIPT><SCRIPT language=JavaScript type=text/javascript>
    <!--
    var ggg=0;
    function change(uuu) 
    {
    for (var i=0;i<document.formviewarea.list2.options.length;i++){
    document.formviewarea.list2.options[i].value="";
    document.formviewarea.list2.options[i].text="";
    }
    BumpUp(formViewArea.list2);
    if (1) SortD(formViewArea.list2);var zzz= "div"+uuu;
    if (ggg>0)
       {
    oldObj.style.display="none";
    }
    else{
    div1.style.display="none";
    }
    document.all(zzz).style.display="";
    oldObj=document.all(zzz);
    ggg+=1;     var table = new Array('T4','T9','T10','T11');
     with(document.formA)
     {
         for (i=0;i<radioprovince.length;i++)
            {
    if (radioprovince[i].checked)
    {
    document.formviewarea.hiddentext0.value = table[i];
    }
    }
     }
    } function jdreturn(){
    radio1.checked=true;
    if (hiddcontent1.style.display=="" && hiddcontent2.style.display==""){
         hiddcontent1.style.display="none";
         hiddcontent2.style.display="none";
        
       }
    }
    //-->
    </SCRIPT>
    <META content="text/html; charset=gb2312" http-equiv=Content-Type>
    <META content="" name=Keywords><LINK href="../include/tjextend.css" rel=stylesheet 
    type=text/css>
    <STYLE media=screen type=text/css>DIV {
    POSITION: relative
    }
    </STYLE><META content="MSHTML 5.00.3315.2870" name=GENERATOR></HEAD>