vadd.asp

来自「ASP入门与提高实用教程 源文件(上传网站)」· ASP 代码 · 共 120 行

ASP
120
字号
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/const.asp"-->
<!--#include file="../inc/config.asp"--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style/3.css" type="text/css">
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	background-color: #CCCCCC;
}
-->
</style></head>

<body>
<% 
checkadmin()
dim options,id,multi
dim rs,i
dim opt()
ID=encodestr(Request("ID"))
options=encodestr(Request("options"))
multi=encodestr(Request("multi"))

if multi="" then multi=0
if options="" then options=0

if cint(options) > cint(maxoptions) then options=maxoptions

redim opt(options+1)

if id<>"" then
	set rs=conn.execute("select count(*) from [vote] where id="&id)
	if  rs.eof then
		session("error")=session("error") & "投票不存在!!<br>"
		rsclose()
		connclose()
		response.redirect("error.asp")
    end if
	options=rs(0)-1
	redim opt(options+1)
	rs.close
	
	set rs=conn.execute("select * from [vote] where id="&id&" order by options")
	i=0
	while not rs.eof
	opt(i)=rs("title")
	i=i+1
	rs.movenext
	wend
end if
 %>
  <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center">投票添加</td>
    </tr>
    <tr>
      <td height="105">
	  <% if options<>0  then %>	  
	  <form name="form1" method="post" action="Vaddo.asp">
	  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="9%">标题</td>
          <td width="76%"><input name="opt" type="text" id="opt" size="50" value=<%= opt(0) %>></td>
          <td width="15%">&nbsp;</td>
        </tr>
		<% for i=0 to options-1 %>	
  		<tr>
          <td>选项</td>
          <td><input name="opt" type="text" id="opt" size="50" value=<%= opt(i+1) %>></td>
          <td>&nbsp;</td>
        </tr>
		<% next %>
      </table>
	  <% Else %>
	  <form name="form1" method="post" action="vadd.asp">
	<table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="12%">选项个数</td>
          <td colspan="2"><select name="options" id="options">
            <option value="1">1</option>
             <option value="2">2</option>
            <option value="3">3</option>
            <option value="4" selected>4</option>
            <option value="5">5</option>
             <option value="6">6</option>
          </select></td>
          <td width="15%">&nbsp;</td>
        </tr>
        <tr>
          <td>是否多选</td>
          <td width="35%">是
            <input type="radio" name="multi" value="1"></td>
          <td width="38%">否
            <input name="multi" type="radio" value="0" checked></td>
          <td>&nbsp;</td>
        </tr>
      </table>

	  <% end if %></td>
    </tr>
    <tr>
      <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="10%">&nbsp;</td>
          <td width="33%" align="right"><input name="ID" type="hidden" id="ID" value="<%= ID %>">
		  <input name="multi1" type="hidden" id="multi" value="<%= multi %>">
            <input type="submit" name="Submit" value="提交"></td>
          <td width="36%" align="center"><input type="reset" name="Submit2" value="重置"></td>
          <td width="21%">&nbsp;</td>
        </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?