ASP+VML+DB实现投票统计项目

ILYiln

ILYiln

2016-01-29 17:47

ASP+VML+DB实现投票统计项目,ASP+VML+DB实现投票统计项目
 

       几个月前我看到过一位网友lshdic写的一篇用JS+VML的《使用 Vml 制作立体柱状投票统计图的完整程序》。
       我觉得这个方法非常不错,可以不使用图片就生成统计图,现在就让我们一起来用ASP实现这个程序。

      准备工作:用ACCESS建立一个MDB数据库,名为vote.mdb,并且在数据库中建立如下两个表:

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/asp/)

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/asp/)



然后建立我们按照ASP开发的惯例建立连接数据库的文件conn.asp
<%
'conn.asp

Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("vote.mdb")
%

显示投票项目的列表,因为我们要制作的是一个多项目的投票系统vote_list.asp
<!--#include file="conn.asp"--
<html
<head
<title投票项目列表</title
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"
<link href="../images/main.css" rel="stylesheet" type="text/css"
</head

<%
set rs=conn.execute("select * from votetitle order by voteid desc")
%
<table border=1 cellspacing="0" style="border-collapse: collapse" cellpadding="0" bgcolor="#ffffff" bordercolor="#000000" width=100%
  <tr
    <td bgcolor="#EFEFEF"所有投票列表</td
  </tr
  <%do while not rs.eof%
  <tr
    <td编号:<font color="#FF0000"<%=rs("voteid")%&nbsp; </font<a href="vote.asp?voteid=<%=rs("voteid")%" target="_blank"<%=rs("votetitle")%
      </a(<%=rs("time")%)</td
  </tr
  <%rs.movenext 
loop 
rs.close
set rs=nothing%
</table
</body
</html

投票显示页面vote_show.asp
<%if request("voteid")="" then
response.write "参数没有指定。"
response.End()
end if%
<!--#include file="conn.asp"--
<html
<head
<title查看结果</title
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"
<STYLE
td{font-size:12px}
body{font-size:12px}
v:*{behavior:url(#default#VML);} //这里声明了v作为VML公用变量
</STYLE
<link href="../images/main.css" rel="stylesheet" type="text/css"
</head
<%
dim voteid
voteid=request("voteid")
set rs=conn.execute("select count from vote,votetitle where votetitle.voteid="&voteid&" and vote.voteid=votetitle.voteid order by id")
iii=0
do while not rs.eof
ii=ii+1
if ii=1 then
ceocio=trim(rs("count"))
ceocio1=trim("array1["&iii&"]")
else
ceocio=trim(ceocio&","&rs("count"))
ceocio1=trim(ceocio1&"+array1["&iii&"]")
end if
iii=iii+1
rs.movenext 
loop 
rs.close
set rs=nothing
'response.write ii
'response.write ceocio1
%
<script
array1=new Array(<%=ceocio%) //不同的投票票数
allstr=<%=ceocio1%
//alert(allstr)
//allstr=array1[0]+array1[1]+array1[2]+array1[3]+array1[4]+array1[5] //得到总数
for(i=0;i<=<%=(ii-1)%;i++){
mathstr=Math.round(100/(allstr/array1[i])) //求百分之几, 100/(总和/单个)
document.write ("<v:rect fillcolor='lime' style='width:20;color:navy;height:"+500*<%=(ii-1)%/(1000/mathstr)+"'<br&nbsp;%"+mathstr+"<br"+array1[i]+"人<v:Extrusion backdepth='15pt' on='true'/</v:rect")

展开更多 50%)
分享

猜你喜欢

ASP+VML+DB实现投票统计项目

ASP
ASP+VML+DB实现投票统计项目

ASP制作在线人数统计实例

Web开发
ASP制作在线人数统计实例

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

iOS统计项目的代码总行数

编程语言 网络编程
iOS统计项目的代码总行数

jsp 实现在线人数统计

Web开发
jsp 实现在线人数统计

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

如何用ASP编写网站统计系统

ASP
如何用ASP编写网站统计系统

用ajax实现的自动投票的代码

Web开发
用ajax实现的自动投票的代码

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

必备!Win XP系统安装经典技巧

必备!Win XP系统安装经典技巧

用Asp隐藏文件路径实现防盗链

用Asp隐藏文件路径实现防盗链
下拉加载更多内容 ↓