标题:Asp投票系统的问题
只看楼主
0987
Rank: 1
等 级:新手上路
帖 子:155
专家分:0
注 册:2005-4-22
 问题点数:0 回复次数:8 
Asp投票系统的问题

一:怎么图片会随投票总数而自动变长度??<img src=”---“ width=”<这里我不会写>” height=”10”

二:怎么计算得票率?

搜索更多相关主题的帖子: Asp 系统 投票 得票率 height 
2005-05-28 18:56
0987
Rank: 1
等 级:新手上路
帖 子:155
专家分:0
注 册:2005-4-22
得分:0 
怎么没人理呀~~~~~~~~~~~~`高手呢~~~~~~~~~~~`你跑哪里去??

我有型~~http://www.~~只是我有我风格
2005-05-29 19:49
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
这个可以这么写

&lt;img src=…… width=&lt;%=choices%&gt; 不用加"号直接等于也可以。
2005-05-29 20:19
0987
Rank: 1
等 级:新手上路
帖 子:155
专家分:0
注 册:2005-4-22
得分:0 
楼上错的。<img src="" width="<%=票数/总票和*100%>%">

但我怎么对应它各自投票的和呀??

我有型~~http://www.~~只是我有我风格
2005-05-29 20:50
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
一会我给你写一个完整的,,呵呵,

面朝大海,春暖花开!
2005-05-31 15:22
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
sub定义个过程

&lt;%
sub ShowVote()
 dim sqlVote,rsVote,i
 sqlVote="select top 1 * from Vote where IsSelected=True"
 Set rsVote= Server.CreateObject("ADODB.Recordset")
 rsVote.open sqlVote,conn,1,1
 if rsVote.bof and rsVote.eof then
  response.Write "&amp;nbsp;&Atilde;&raquo;&Oacute;&ETH;&Egrave;&Icirc;&ordm;&Icirc;&micro;÷&sup2;é"
 else
  response.write "&lt;form name='VoteForm' method='post' action='vote.asp' target='_blank'&gt;&lt;td&gt;"
  response.write "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; rsVote("Title") &amp; "&lt;br&gt;"
  if rsVote("VoteType")="Single" then
   for i=1 to 3
    if trim(rsVote("Select" &amp; i) &amp; "")="" then exit for
    response.Write "&lt;input type='radio' name='VoteOption' value='" &amp; i &amp; "'&gt;" &amp; rsVote("Select" &amp; i) &amp; "&lt;br&gt;"
   next
  else
   for i=1 to 3
    if trim(rsVote("Select" &amp; i) &amp; "")="" then exit for
    response.Write "&lt;input type='checkbox' name='VoteOption' value='" &amp; i &amp; "'&gt;" &amp; rsVote("Select" &amp; i) &amp; "&lt;br&gt;"
   next
  end if
  response.write "&lt;br&gt;&lt;input name='VoteType' type='hidden'value='" &amp; rsVote("VoteType") &amp; "'&gt;"
  response.write "&lt;input name='Action' type='hidden' value='Vote'&gt;"
  response.write "&lt;input name='ID' type='hidden' value='" &amp; rsVote("ID") &amp; "'&gt;"
  response.write "&lt;div align='center'&gt;"
  response.write "&lt;a href='javascript:VoteForm.submit();'&gt;&lt;img src='imgs/voteSubmit.gif' width='52' height='18' border='0'&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;"
        response.write "&lt;a href='Vote.asp?Action=Show' target='_blank'&gt;&lt;img src='imgs/voteView.gif' width='52' height='18' border='0'&gt;&lt;/a&gt;"
  response.write "&lt;/div&gt;&lt;/td&gt;&lt;/form&gt;"
 end if
 rsVote.close
 set rsVote=nothing
end sub %&gt;

面朝大海,春暖花开!
2005-05-31 17:31
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
这是vote.asp
&lt;!--#include file="conn.asp" --&gt;
&lt;%
dim Action,ID,VoteType,VoteOption,sqlVote,rsVote
Action=trim(Request("Action"))
ID=Trim(request("ID"))
VoteType=Trim(request("VoteType"))
VoteOption=trim(request("VoteOption"))
If Action = "Vote" And Id&lt;&gt; "" And VoteOption&lt;&gt;"" And Session("Voted") = "" Then
 if VoteType="Single" then
  conn.execute "Update Vote set answer" &amp; VoteOption  &amp; "= answer" &amp; VoteOption &amp; "+1 where ID=" &amp; ID
 else
  dim arrOptions
  if instr(VoteOption,",")&gt;0 then
   arrOptions=split(VoteOption,",")
   dim i
   for i=0 to ubound(arrOptions)
    conn.execute "Update Vote set answer" &amp; cint(trim(arrOptions(i)))  &amp; "= answer" &amp; cint(trim(arrOptions(i))) &amp; "+1 where ID=" &amp; Clng(ID)
   next
  else
   conn.execute "Update Vote set answer" &amp; VoteOption  &amp; "= answer" &amp; VoteOption &amp; "+1 where ID=" &amp; Clng(ID)
  end if
 end if
 session("Voted")="True"
End If
if ID&lt;&gt;"" then
 sqlVote="Select * from Vote Where ID=" &amp; Clng(ID)
else
 sqlVote="select top 1 * from Vote order by ID desc"
end if
Set rsVote = Server.CreateObject("ADODB.Recordset")
rsVote.open sqlVote,conn,1,1
%&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;调查结果&lt;/TITLE&gt;
&lt;META http-equiv=Content-Type content="text/html; charset=gb2312"&gt;
&lt;style type="text/css"&gt;
A:link    {  color: #333333;TEXT-DECORATION: none }
A:visited {  color: #333333;TEXT-DECORATION: none }
A:active  {  color: #003300;TEXT-DECORATION: none }
A:hover   {  color: #003300;TEXT-DECORATION: underline overline }
.navtrail {  COLOR: #eeeeee; FONT-SIZE: 12px; LINE-HEIGHT: 12px }
A.navtrail:link {  COLOR: #eeeeee; CURSOR: w-resize }
A.navtrail:visited {  COLOR: #eeeeee; CURSOR: w-resize }
A.navtrail:active {  COLOR: #eeeeee; CURSOR: w-resize }
A.navtrail:hover {  COLOR: #eeeeee; CURSOR: e-resize }
INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}
&lt;!--
td {  font-family: "宋体"; font-size: 9pt; color: #333333; text-decoration: none}
--&gt;
&lt;/style&gt;
&lt;/HEAD&gt;
&lt;BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"&gt;
&lt;table width="600" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#C4D3FF"&gt;
  &lt;tr&gt;
      &lt;td valign="top"&gt;
&lt;%
if Action="Vote" and session("voted")&lt;&gt;"" then
 response.write "&lt;font color='#FF0000' size='4'&gt;"
    if Session("UserName")&lt;&gt;"" then response.write Session("UserName") &amp; ","
 response.write "&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;非常感谢您的投票!&lt;/font&gt;&lt;br&gt;"
end if
  %&gt;
      &lt;table width="600" border="0" align="center" cellpadding="2" cellspacing="0" class="border"&gt;
        &lt;tr align="center" class="title"&gt;
          &lt;td height="35" colspan="3"&gt;&lt;strong&gt;&lt;font color="#FFFFFF"&gt;调 查 结 果&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr class="tdbg"&gt;&lt;td&gt;
   &lt;table width="600" border="0" align="center" cellpadding="0" cellspacing="2"&gt;
              &lt;tr&gt;
                &lt;td width="140" align="right"&gt;&lt;div align="center"&gt;&lt;strong&gt;&lt;font color="#FFFFFF"&gt;调查内容:&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td colspan="2"&gt;&lt;font color="#FFFFFF"&gt;&lt;%=rsVote("Title")%&gt;&lt;/font&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td width="140" align="right"&gt;&lt;div align="center"&gt;&lt;strong&gt;&lt;font color="#FFFFFF"&gt;总投票数:&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td colspan="2"&gt;
                  &lt;font color="#FFFFFF"&gt;&lt;%
  dim totalVote
  totalVote=0
  for i=1 to 8
   if rsVote("Select" &amp; i)="" then exit for
 totalVote=totalVote+rsVote("answer"&amp; i)
  next
  response.Write(totalVote &amp; "票")
  if totalVote=0 then totalVote=1
  %&gt;&lt;/font&gt;
                &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td colspan="3" align="center"&gt;&amp;nbsp;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td width="140" align="center"&gt;&lt;font color="#FFFFFF"&gt;&lt;strong&gt;投票选项&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;
                &lt;td width="64" align="right"&gt;&lt;div align="center"&gt;&lt;font color="#FFFFFF"&gt;&lt;strong&gt;票数&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td width="388" align="center"&gt;&lt;font color="#FFFFFF"&gt;&lt;strong&gt;百分比&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;%
  for i=1 to 8
   if trim(rsVote("Select" &amp; i) &amp; "")="" then exit for
  %&gt;
              &lt;tr&gt;
                &lt;td width="140" align="right"&gt;&lt;div align="center"&gt;&lt;font color="#ffffff"&gt;&lt;%=rsVote("Select"&amp; i)%&gt;&lt;/font&gt;
                  &lt;/div&gt;&lt;/td&gt;
                &lt;td align="right"&gt;
                  &lt;div align="center"&gt;&lt;%
 response.write rsVote("answer"&amp; i)
 %&gt;
                  &lt;/div&gt;&lt;/td&gt;
                &lt;td&gt;
                  &lt;%
 dim perVote
 perVote=round(rsVote("answer"&amp; i)/totalVote,4)
 response.write "&lt;img src='imgs/topBar_bg.gif' width='" &amp; round(360*perVote) &amp; "' height='15' align='absmiddle'&gt;"
 perVote=perVote*100
 if perVote&lt;1 and perVote&lt;&gt;0 then
  response.write "&amp;nbsp;0" &amp; perVote &amp; "%"
 else
  response.write "&amp;nbsp;" &amp; perVote &amp; "%"
 end if
 %&gt;
                &lt;/td&gt;
              &lt;/tr&gt;
              &lt;% next %&gt;
            &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
      &lt;%
if session("voted")="" then
  if Session("UserName")&lt;&gt;"" then
   response.write Session("UserName") &amp; ","
  end if
     response.Write "&lt;br&gt;&lt;br&gt;您还没有投票,请您在此投下您宝贵的一票!"
  response.write "&lt;form name='VoteForm' method='post' action='vote.asp'&gt;"
  response.write "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;" &amp; rsVote("Title") &amp; "&lt;br&gt;"
  if rsVote("VoteType")="Single" then
   for i=1 to 3
    if trim(rsVote("Select" &amp; i) &amp; "")="" then exit for
    response.Write "&lt;input type='radio' name='VoteOption' value='" &amp; i &amp; "'&gt;" &amp; rsVote("Select" &amp; i) &amp; "&lt;br&gt;"
   next
  else
   for i=1 to 3
    if trim(rsVote("Select" &amp; i) &amp; "")="" then exit for
    response.Write "&lt;input type='checkbox' name='VoteOption' value='" &amp; i &amp; "'&gt;" &amp; rsVote("Select" &amp; i) &amp; "&lt;br&gt;"
   next
  end if
  response.write "&lt;br&gt;&lt;input name='VoteType' type='hidden'value='" &amp; rsVote("VoteType") &amp; "'&gt;"
  response.write "&lt;input name='Action' type='hidden' value='Vote'&gt;"
  response.write "&lt;input name='ID' type='hidden' value='" &amp; rsVote("ID") &amp; "'&gt;"
  response.write "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href='javascript:VoteForm.submit();'&gt;&lt;img src='imgs/voteSubmit.gif' width='52' height='18' border='0'&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;"
        response.write "&lt;a href='Vote.asp?ID=" &amp; rsVote("ID") &amp; "&amp;Action=Show' target='_blank'&gt;&lt;img src='imgs/voteView.gif' width='52' height='18' border='0'&gt;&lt;/a&gt;"
  response.write "&lt;/form&gt;"
end if
dim sqlOtherVote,rsOtherVote
sqlOtherVote="Select * from Vote Where ID&lt;&gt;" &amp; ID &amp; " order by ID desc"
Set rsOtherVote = Server.CreateObject("ADODB.Recordset")
rsOtherVote.open sqlOtherVote,conn,1,1
rsOtherVote.close
set rsOtherVote=nothing
%&gt;
      &lt;p align="center"&gt;【&lt;a href="javascript:window.close();"&gt;&lt;font color="#FFFFFF"&gt;关闭窗口&lt;/font&gt;&lt;/a&gt;】&lt;br&gt;
        &lt;br&gt;
      &lt;/p&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
&lt;%
rsVote.Close()
Set rsVote = Nothing
call CloseConn()
%&gt;

面朝大海,春暖花开!
2005-05-31 17:32
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
得分:0 
找个地方调用一下就可以了,,

面朝大海,春暖花开!
2005-05-31 17:33
lingzi7780
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-7-3
得分:0 
好人那
2007-07-03 17:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-19575-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.389316 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved