📄 poll_modi.asp
字号:
<!--#include file="../../include/db.asp"-->
<!--#include file="../../include/admin_check.asp"-->
<!--#include file="power.asp"-->
<%
'********************************************
'本文件中 xml 文件的表示方法
' A.B.C 代表 xml 下的层次结构,C 是 B 的子接点,B 是 A 的子接点
' A:B 代表 xml 下的元素属性,B 是 A 的属性
'
'********************************************
'双引号转换函数 xmlchar 中所有的双引号都用 ~ 号代替,最后转换
function Deal(mystring)
arrName=replace(mystring,"~",chr(34))
Deal=(arrName)
end function
'特殊字符转换程序
function Deal(initstring)
tempstring=replace(initstring,chr(39),"’")
tempstring=Replace(tempstring,"<","<")
tempstring=Replace(tempstring,">",">")
tempstring=replace(tempstring,chr(34),"“")
tempstring=replace(tempstring,chr(32)," ")
deal=(tempstring)
end function
function Dealname(mystring)
arrName=split(Cstr(mystring),chr(34))
Dealname=arrName(1)
end function
'*********************************************载入 poll.xml 文件
id=trim(request("id"))
if id="" or not(isnumeric(id)) then
Response.Write "<script language=javascript>"
Response.Write "alert('错误的参数!!');"
Response.Write "history.go(-1);"
Response.Write "</script>"
Response.End
end if
path=server.mappath("poll.xml")
set myDoc=Server.CreateObject("microsoft.xmldom")
myDoc.async=False
myDoc.load(path)
set xmlTop=myDoc.documentElement
'判断问卷调查是否存在
itemExist=falue
for i=0 to xmlTop.childNodes.length-1
itemId=xmlTop.childNodes.item(i).attributes.getNamedItem("id").nodeValue
if itemId=id then
set itemNode=xmlTop.childNodes.item(i)
ItemExist=true
exit for
end if
next
if not itemExist then
Response.Write "<script language=javascript>"
Response.Write "alert('该问卷调查不存在!!');"
Response.Write "history.go(-1);"
Response.Write "</script>"
Response.End
end if
'如果已经有人投票,则不允许修改
if itemNode.attributes.getNamedItem("polled").nodeValue<>0 then
Response.Write "<script language=javascript>"
Response.Write "alert('该问卷调查已经有人投票,请先把投票记录清零,否则不允许修改!!');"
Response.Write "history.go(-1);"
Response.Write "</script>"
Response.End
end if
'如果已经在发布中,则不允许修改
if itemNode.attributes.getNamedItem("status").nodeValue=1 then
Response.Write "<script language=javascript>"
Response.Write "alert('该问卷调查正在发布,请先停止使用,否则不允许修改!!');"
Response.Write "history.go(-1);"
Response.Write "</script>"
Response.End
end if
itemNum=itemNode.childNodes.length
action=trim(request.querystring("action"))
if action="add" or action="addItem" then
'*********************************************编辑 poll.xml 文件
'修改标题<title>的属性值
if trim(request("title"))="" then
Response.Write "<script language=javascript>"
Response.Write "alert('标题不能为空!!');"
Response.Write "history.go(-1);"
Response.Write "</script>"
Response.End
end if
itemNode.attributes.getNamedItem("title").nodeValue=deal(trim(request("title")))
'清除原来所有的<select>节点
dim removeNode()
redim removeNode(itemNum)
for i=0 to itemNum-1
set removeNode(i)=itemNode.removeChild(itemNode.childNodes.item(0))
next
'重新写入各节点值
newId=1
for each x in request("select")
if trim(x)<>"" then
set selectNode=myDoc.createElement("select")
'插入投票次数<polled>属性
set attNode=myDoc.createAttribute("polled")
set textNode=myDoc.createTextNode("0")
attNode.appendChild(textNode)
selectNode.attributes.setNamedItem(attNode)
'插入<select>节点的<id>属性值
set attNode=myDoc.createAttribute("id")
set textNode=myDoc.createTextNode(newId)
attNode.appendChild(textNode)
selectNode.attributes.setNamedItem(attNode)
set textNode=myDoc.createTextNode(deal(x))
selectNode.appendChild(textNode)
itemNode.appendChild(selectNode)
newId=newId+1
end if
next
myDoc.save(path)
'Response.Write "<script language=javascript>"
'Response.Write "alert('操作成功!!');"
'Response.Write "window.location.href='poll.asp';"
'Response.Write "</script>"
'Response.End
response.redirect "poll.asp"
end if
%><html>
<head>
<title>深圳育才一小欢迎您!</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/include/page.css" type="text/css">
</head>
<body >
<table width="1" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="753" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<!--#include file="../../include/admin_banner.inc"-->
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%"> </td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -