那我还没做过,应该用applet或servlet吧,比这个麻烦

解决方案 »

  1.   

    xiaofenguser(风雨)
    能不能给我一个,谢谢先。
    [email protected]
      

  2.   

    很简单的,贴上来吧.这个是投票用的,原理一样
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="/err.jsp"%>
    <jsp:useBean id="dbcon" scope="page" class="com.data.DBConnect"/>
    <%
    String vote_id=request.getParameter("vote_id");
    String query="select choice.*,vote.vote_content,vote.vote_result from vote,choice ";
    query+="where choice.vote_id='"+vote_id+"' and choice.vote_id=vote.vote_id";
    ResultSet rs=dbcon.executeQuery(query);
    double result=0;
    String vote_content="";
    if(rs.next()){
    vote_content=rs.getString("vote_content");
    result=rs.getDouble("vote_result");
    %>
    <style type="text/css">
    <!--
    .unnamed1 {
    font-size: 14px;
    }
    -->
    </style><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td height="34" colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
              <td height="40" class="unnamed1">调查内容:<strong><%=vote_content%></strong> </td>
            </tr>
            <tr> 
              <td height="40" class="unnamed1">(目前共有<font color="#FF0000"><%=(int)result%></font>票!)</td>
            </tr>
          </table>
          <hr> </td>
      </tr>
      <tr> 
        <td class="unnamed1">&nbsp;</td>
        <td width="480"> <table width="480" border="0" cellspacing="0" cellpadding="0">
            <%
      
      do{
      String choice_content=rs.getString("choice_content");
      double choice_result=rs.getDouble("choice_result");
      %>
            <tr> 
              <td width="110" height="40"><img src="/vote/red.gif" width="<%
    if(result<1)
    {
    out.print(100);
    }else{
    out.print(100*choice_result/result);
    }%>" height="20"></td>
              <td width="190" class="unnamed1"><%=choice_content%></td>
              <td width="180" class="unnamed1">已有<font color="#FF0000"><%=(int)choice_result%></font>票, 
                <%
    if(result<1)
    {
    out.print("");
    }else{
    double kkkey=10000*choice_result/result;
    out.print("占总数的"+(int)kkkey/100.00+"%");
    }
    %></td>
            </tr>
            <%}while(rs.next());
    rs.close();
    dbcon.destroy();
     %>
          </table>
          <%}%></td>
        <td>&nbsp;</td>
      </tr>
      <tr> 
        <td colspan="3"><hr></td>
      </tr>
    </table>