代码:
    <form action="" method="post">
     <table align="center">
         <tr><td width="140">你最喜欢的网络游戏是:</td></tr>
<tr><td><input type="checkbox" name="游戏1">&nbsp;&nbsp;&nbsp;&nbsp;魔&nbsp;兽&nbsp;争&nbsp;霸</td></tr>
<tr><td><input type="checkbox" name="游戏2">&nbsp;&nbsp;&nbsp;&nbsp;热&nbsp;血&nbsp;传&nbsp;奇</td></tr>
<tr><td><input type="checkbox" name="游戏3">&nbsp;&nbsp;&nbsp;&nbsp;传&nbsp;说&nbsp;Online</td></tr>
<tr><td><input type="checkbox" name="游戏4">&nbsp;&nbsp;&nbsp;&nbsp;街&nbsp;头&nbsp;篮&nbsp;球</td></tr>
<tr><td><input type="checkbox" name="游戏5">&nbsp;&nbsp;&nbsp;&nbsp;反&nbsp;恐&nbsp;精&nbsp;英</td></tr>
<tr><td><input type="checkbox" name="游戏6">&nbsp;&nbsp;&nbsp;&nbsp;泡&nbsp;&nbsp;&nbsp;泡&nbsp;&nbsp;&nbsp;&nbsp;堂</td></tr>
<tr align="right"><td><input type="submit" name="" value="提交/查询">&nbsp;&nbsp;&nbsp;<input type="reset"></td></tr>
     </table>
     </form> 
    怎么才能在提交后网页上生成柱状的图形(不需要把这些消息送到数据库),画面上显示各个游戏显示占总投票的比例了。
    问题急需解决,分不够在给。

解决方案 »

  1.   

    用开源的代码,
    freechart等等,可以做到,很简单
      

  2.   

    帮你顶,上Google搜索一下FreeChart关键字看看
      

  3.   

    使用jfreechar就完全可以了!!!
      

  4.   

    不需要把这些消息送到数据库?米懂楼主的意思~不入库你其他人投票的数据怎么来?或者?跑个全局的application?
      

  5.   

    传统而简单的方法:自己写个画柱状图的servlet
      

  6.   

    www.joyistar.com
    演示中有个柱状图
      

  7.   

    肯定要先作一下数据库的持久化吧,不管你是放到数据库里,还是放到哪里。。然后,再用 jfreechart 画图就可以了。网上有很多例子的。接分
      

  8.   

    最简单的办法就是用一个横线做表格的背景,根据数值的不同来调整其高度,改变一下valign属性就可达到目的了,如果是高级应用那也就是jfree了
      

  9.   

    \ 回复人: findme123(飞翔的叶子) ( ) 信誉:100  2006-2-15 14:05:20  得分: 0  
    \告诉我邮箱我给你发个现成的
    fe非常感谢。
      

  10.   

    哇呵呵看看,http://khhqy.Lun123.com 我的创业网!
    现向全国招骋,主要工作:上网发发电子邮件,聊天等!
      

  11.   

    case "B":
     var table_space = (all_height - table_width * total_no) / total_no;
     document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length) + "px," + (table_y+all_height-length) + "px' to='" + (table_x+left_width+all_width) + "px," + (table_y+all_height-length) + "px' strokecolor='" + line_color + "'/><![endif]-->");
       temp4 =temp3/5;
     for(var i=0;i<=all_width-1;i +=all_width/5)
     {
      document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+i) + "px," + (table_y+all_height-length) + "px' to='" + (table_x+left_width+length+i) + "px," + (table_y+all_height) + "px' strokecolor='" + line_color + "'/><![endif]-->");
      document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+length+i) + "px," + (table_y+all_height-length) + "px' to='" + (table_x+left_width+length+i) + "px," + table_y + "px' strokecolor='" + line_color + "'/><![endif]-->");
      document.write("<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='" + (table_x+left_width+i+all_width/5) + "px," + (table_y+all_height) + "px' to='" + (table_x+left_width+i+all_width/5) + "px," + (table_y+all_height+15) + "px'/><![endif]-->");
      document.write("<!--[if gte vml 1]>");
      document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x+left_width+i+all_width/5-left_width) + "px;top:" + (table_y+all_height) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
      document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + temp4 + "</td></tr></table></v:textbox></v:shape><![endif]-->");
      temp4 = temp4 + temp3 / 5;
     }
     
     for(var i=0;i<total_no;i++)
     {
      var temp_space = table_space/2 + table_space * i + table_width * i;
      document.write("<v:rect id='_x0000_s1025' alt='' style='position:absolute;left:");
      document.write(table_x + left_width);
      document.write("px;top:");
      document.write(table_y + temp_space);
      document.write("px;width:" + all_width * (total[0][i] / temp3) + "px;height:" + table_width + "px;z-index:1' fillcolor='" + tb_color[1][i] + "'>");
      document.write("<v:fill color2='" + tb_color[0][i] + "' rotate='t' angle='-90' focus='100%' type='gradient'/>");
      document.write("<o:extrusion v:ext='view' backdepth='" + thickness + "pt' color='" + tb_color[1][i] + "' on='t'/>");
      document.write("</v:rect>");
      document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + (table_x + left_width + all_width * (total[0][i] / temp3) + thickness / 2) + "px;top:" + (table_y + temp_space) + "px;width:" + (table_space + 15) + "px;height:18px;z-index:1'>");
      document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>" + total[0][i] + "</td></tr></table></v:textbox></v:shape>");
     
      document.write("<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:" + table_x + "px;top:" + (table_y + temp_space) + "px;width:" + left_width + "px;height:18px;z-index:1'>");
      document.write("<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>" + total[1][i] + "</td></tr></table></v:textbox></v:shape>");
     }
     
     }
    }
    </script>
    <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
    <!--[if !mso]>
    <style>
    v\:*         { behavior: url(#default#VML) }
    o\:*         { behavior: url(#default#VML) }
    .shape       { behavior: url(#default#VML) }
    </style>
    <![endif]-->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title></title>
    <style>
    TD { FONT-SIZE: 9pt}
    </style></head>
    <body topmargin=5 leftmargin=0 scroll=AUTO>
    <script language=javascript>
    //=============调用方法=====================
    var dataArray = new Array()
    dataArray[0]=200
    dataArray[1]=800
    dataArray[2]=1000
    dataArray[3]=600
    dataArray[4]=1222
    dataArray[5]=3213
    dataArray[6]=8
    var nameArray = new Array()
    nameArray[0]="中国经营报"
    nameArray[1]="招聘网"
    nameArray[2]="51Job"
    nameArray[3]="新民晚报"
    nameArray[4]="新闻晚报"
    nameArray[5]="南方周末"
    nameArray[6]="羊城晚报"
    var total= new Array(dataArray,nameArray)
    table1(total,200,20,20,30,400,200,"A");
    table1(total,200,320,20,20,400,250,"B")
    </script>
    </body>
    </html>
      

  12.   


    先在登陆页设置application ,game1,game2,…game6变量页面代码如下。通过<TD>产生柱型效果<form action="GameSurvey.jsp" method="post">
        <table align="center">
          <tr><td width="240">你最喜欢的网络游戏是:</td></tr>
     <tr><td><input type="checkbox" name="game1">魔兽争霸</td></tr>
     <tr><td><input type="checkbox" name="game2">热血传奇</td></tr>
     <tr><td><input type="checkbox" name="game3">传说Online</td></tr>
     <tr><td><input type="checkbox" name="game4">街头篮球</td></tr>
     <tr><td><input type="checkbox" name="game5">反恐精英</td></tr>
     <tr><td><input type="checkbox" name="game6">泡泡堂</td></tr>         <tr align="right"><td><input type="submit" name="" value="提交/查询">&nbsp;&nbsp;&nbsp;<input type="reset"></td></tr>
         </table>
    </form>
    <br>
    <br>
    <br>
    <%
        
      
      int game1 = Integer.parseInt((String)application.getAttribute("game1"));
      int game2 = Integer.parseInt((String)application.getAttribute("game2"));
      int game3 = Integer.parseInt((String)application.getAttribute("game3"));
      int game4 = Integer.parseInt((String)application.getAttribute("game4"));
      int game5 = Integer.parseInt((String)application.getAttribute("game5"));
      int game6 = Integer.parseInt((String)application.getAttribute("game6"));
     
             if(request.getParameter("game1") != null){
      if(!request.getParameter("game1").equals("")){
      game1++;
      }   
      }
      if(request.getParameter("game2") != null){
      if(!request.getParameter("game2").equals("")){
      game2++;
      }   
      }
      if(request.getParameter("game3") != null){
      if(!request.getParameter("game3").equals("")){
      game3++;
      }   
      }
      if(request.getParameter("game4") != null){
      if(!request.getParameter("game4").equals("")){
      game4++;
      }   
      }
      if(request.getParameter("game5") != null){
      if(!request.getParameter("game5").equals("")){
      game5++;
      }   
      }
      if(request.getParameter("game6") != null){
      if(!request.getParameter("game6").equals("")){
      game6++;
      }   
      }
      String temp="";
      application.setAttribute("game1",temp+game1);
      application.setAttribute("game2",temp+game2);
      application.setAttribute("game3",temp+game3);
      application.setAttribute("game4",temp+game4);
      application.setAttribute("game5",temp+game5);
      application.setAttribute("game6",temp+game6);
      
      
    %>
    <table align=center width=70%>
      <tr>
        <td>
      <table>
      <tr>
    <td width=102>魔兽争霸</td>
    <td bgcolor=#996699 height=20 width=<%= game1 * 3 %> align="left"></td></tr>
      </tr>
          </table>
    </td>
      </tr>
      <tr>
        <td>
      <table>
      <tr>
    <td width=102>热血传奇</td>
    <td bgcolor=#996699 height=20 width=<%= game2 * 3 %> align="left"></td></tr>
      </tr>
      </table>
    </td>
      </tr>
      <tr>
        <td>
      <table>
      <tr>
    <td width=102>传说Online</td>
    <td bgcolor=#996699 height=20 width=<%= game3 * 3 %> align="left"></td></tr>
      </tr>
      </table>
    </td>
      </tr>
      <tr>
        <td>
      <table>
      <tr>
    <td width=102>街头篮球</td>
    <td bgcolor=#996699 height=20 width=<%= game4 * 3 %> align="left"></td></tr>
      </tr>
      </table>
    </td>
      </tr>
      <tr>
        <td>
      <table>
      <tr>
    <td width=102>反恐精英</td>
    <td bgcolor=#996699 height=20 width=<%= game5 * 3 %> align="left"></td></tr>
      </tr>
      </table>
    </td>
      </tr>
      <tr>
        <td>
      <table>
      <tr>
    <td width=102>泡泡堂</td>
    <td bgcolor=#996699 height=20 width=<%= game6 * 3 %> align="left"></td></tr>
      </tr>
      </table>
    </td>
      </tr>  
    </table>