打印本文 打印本文  关闭窗口 关闭窗口
ASP+VML+DB实现投票统计项目
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005/9/10 12:39:22
width=100%>
  <tr>
    <td bgcolor="#EFEFEF"><center>
        添加新的投票</center></td>
  </tr>
  <tr>
    <td>请输入这个投票所需要的选项个数。</td>
  </tr>
  <tr>
    <td><form name="form1" method="post" action="?action=add1">
        <select name="num">
  <%for i1=2 to 10%>
          <option value="<%=i1%>"><%=i1%></option>
  <%next%>
        </select>
        <input type="submit" name="Submit" value="Submit">
      </form></td>
  </tr>
</table>
<%
end if
if action="add1" then
num=request("num")
%>
<table border=1 cellspacing="0" style="border-collapse: collapse" cellpadding="0" bgcolor="#ffffff" bordercolor="#C0C0C0" width=100%>
  <tr>
    <td bgcolor="#EFEFEF"><center>
        添加新的投票</center></td>
  </tr>
  <tr>
    <td>请输入这个投票所需要的详细信息。</td>
  </tr>
  <tr>
    <td><form name="form2" method="post" action="?action=add2">
        投票名称
        <input type="text" name="votetitle">
        <br>
  <%for i2=1 to num%>
        选项<%=i2%><input type="text" name="<%=i2%>"><br>
        <%next%>
        <input type="hidden" name="num" value="<%=request("num")%>">
        <input type="submit" name="Submit2" value="Submit">
        <input type="reset" name="Submit3" value="Reset">
      </form></td>
  </tr>
</table>

<%end if
if action="add2" then
Set rs=Server.CreateObject("ADODB.Recordset")
sql="SELECT * FROM votetitle"
rs.Open sql,conn,1,3
rs.Addnew
rs("votetitle")=request("votetitle")
rs("time")=date()
rs.Update
rs.Close
set rs=conn.execute("select top 1 voteid from votetitle order by voteid desc")
voteid=rs("voteid")
rs.close
set rs=nothing
'//////////////
'/////////////循环
num=request("num")
for i3=1 to num
Set rs=Server.CreateObject("ADODB.Recordset")
sql="SELECT * FROM vote"
rs.Open sql,conn,1,3
rs.Addnew
rs("title")=request(i3)
rs("voteid")=voteid
rs.Update
rs.Close
next
'////////////循环结束
Set rs=Nothing
response.Write "<a href=admin_vote_list.asp>成功添加,请返回</a>"
end if
'修改表单结束
'////////////////////
'修改执行代码
'修改执行代码结束
%>

<%if action="" then
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="#C0C0C0" width=100%>
  <tr>
    <td colspan="2" bgcolor="#EFEFEF">所有投票列表</td>
  </tr>
  <%do while not rs.eof%>
  <tr>
    <td width="44%">编号:<font color="#FF0000"><%=rs("voteid")%>&nbsp; </font><a href="vote.asp?voteid=<%=rs("voteid")%>" target="_blank"><%=rs("votetitle")%>
      </a>(<%=rs("time")%>)</td>
    <td width="50%">【<a href="?action=del&voteid=<%=rs("voteid")%>">删除</a>】</td>
  </tr>
  <%rs.movenext 
loop 
rs.close
set rs=nothing%>
  <tr>
    <td colspan="2">【<a href="?action=add">添加一个新的投票调查项目</a>】</td>
  </tr>
</table>
</body>
</html>
<%end if%>

最后显示效果如下:


上一页  [1] [2] 



打印本文 打印本文  关闭窗口 关闭窗口