

 |
|
一个投票程序
|
|
|
1. vote.asp
<%@ LANGUAGE="VBSCRIPT"%> <%OPTION EXPLICIT%> <%Response.Buffer = True%>
<!-- #INCLUDE FILE="adovbs.inc" -->
<% '*** Remember to create those variables before trying to use them.
Dim objConn Dim objRec3 Dim strConnect Dim varTopic, varTopicID, varSelectionNum, varSelected Dim i, varTotal, varThis, varThisTitle, varAlreadyVote
strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("vote.mdb") & ";DefaultDir=" & Server.MapPath(".") & ";DriverId=25;FILE=MS Access;MaxBufferSize=512;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;;User Id=admin;" Set objConn = Server.CreateObject ("ADODB.Connection") '*** Create an ADO database connection object. Set objRec3 = Server.CreateObject ("ADODB.Recordset") '** Create an ADO RecordSet object. objConn.Open strConnect '*** Open the connection to the database objRec3.Open "vote", objConn, adOpenForwardOnly, adLockPessimistic, adUseServer '*** Open the recordset
varTopic = Request.Form("topic") varTopicID = Request.Form("topicID") if varTopicID="" then varTopicID = Request.QueryString("topicID") end if varSelectionNum = Request.Form("selectionNum") varSelected = Request.Form("selected")
objRec3.Filter = 0 objRec3.Filter = "topicID=" & varTopicID 'only number can be filter? If NOT objRec3.EOF then if Request.Form("selected") = "" then else varAlreadyVote="alreadyVote" & "_" & varTopicID if Session(varAlreadyVote)<>"true" then objRec3("selection" & varSelected & "_count") = objRec3("selection" & varSelected & "_count") +1 objRec3.Update Session(varAlreadyVote)="true" end if end if varTotal=0 for i=0 to objRec3("selectionNum")-1 varTotal=varTotal+ objRec3("selection" & i & "_count") next %>
<p align=left> <% =varTopic %> </p> <p align=center> <table width=480 border=0 cellspacing=0 cellpadding=0 bgcolor=#000000> <caption align=left><font size=2>共有 <font color=red><% =varTotal %></font>人参加</font></caption> <tr><td> <table width=480 border=0 cellspacing=1 cellpadding=3> <tr bgcolor=#dcdcdc align=center valign=center> <th width=120><font size=2>选项</font></td> <th width=300><font size=2>比 例</font></td> <th width=60><font size=2>人数</font></td> </tr>
<% for i=0 to objRec3("selectionNum")-1 varThisTitle=objRec3("selection" & i & "_title") varThis=objRec3("selection" & i & "_count") %> <tr bgcolor=#ffffff valign=center> <td width=120 align=center><font size=2 color=#ff0000><% =varThisTitle %></font></td> <td width=300 align=left><img src="color.gif" width=<% =varThis*100/varTotal %> height=12 border=0><font size=2 color=#ff0000>
|
|
上一篇:COM编程模型
下一篇:暂无
|
普克创业投资网刊载此文不代表同意其说法或描述,仅为提供更多信息。
|
|
|