国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

解析Asp實現Dig程序中的投票_ASP教程

2024-05-04 11:04:24
字體:
來源:轉載
供稿:網友

推薦:解析如何過濾不文明字符
% Function badchar(str) badstr=不文明字符列表,用|分開(因發表時不能含有那些字符,所以不能貼出。) badword=split(badstr,|) For i=0 to Ubound(badword) If instr(str,badword(i)) 0 then badchar=True Exit For Else badchar=False End If Next

ASP做一個dig程序中的投票(有的叫頂一下,踩一下),由于代碼較長,只貼出核心部分:投票中的代碼

網頁顯示投票的部分:

<div class="Vote1"><script src='/voteResult.asp?id=1&action=view'></script></div>

效果如圖:,然后點投一票,票數增加1,如圖:

voteResult.asp代碼

<%
Response.ContentType="text/html; charset=gb2312"

'作者:無情 來源: 轉載請保留出處
'鏈接數據庫代碼省略
set rs=server.createobject("adodb.recordset")
sql=("select news_id,vote from dwww_news where news_id="&request("id")&"")
rs.open sql,conn,1,1

if not rs.eof and not rs.bof Then '先檢查傳過來的id是否正確

if request("action")="view" Then '如果是新聞代碼中傳來的id
if instr(request.Cookies("voteid"),request("id")&"|")<>0 Then '判斷該id的新聞是否投過票
response.write "document.write (""<div class='result' id='result_"&rs("news_id")&"'>"&rs("vote")&"</div>"");"
response.write "document.write (""<span class='result_link' id='result_link_"&rs("news_id")&"'>投票成功</span>"");"
else
response.write "document.write (""<div class='result' id='result_"&rs("news_id")&"'><a href='javascript:dovote("&request("id")&")'>"&rs("vote")&"</a></div>"");"
response.write "document.write (""<span class='result_link' id='result_link_"&rs("news_id")&"'><a href='javascript:dovote("&request("id")&")'>投一票</a></span>"");"
end if
Else '點擊投票處理代碼
if instr(request.Cookies("voteid"),request("id")&"|")<>0 then
Response.Cookies("voteid")=request("id")&"|"
Response.Cookies("voteid").Expires=Date()+365
else
Response.Cookies("voteid")=request("id")&"|"&request.Cookies("voteid")
Response.Cookies("voteid").Expires=Date()+365
end If

分享:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 襄垣县| 贵定县| 镇宁| 定结县| 剑川县| 庄河市| 禄丰县| 阿巴嘎旗| 田阳县| 井研县| 沐川县| 株洲县| 阳江市| 临湘市| 大英县| 赣榆县| 岱山县| 济阳县| 吴江市| 邢台市| 祁阳县| 成安县| 来安县| 剑川县| 古浪县| 临泉县| 二连浩特市| 河间市| 饶河县| 永嘉县| 虎林市| 德令哈市| 元阳县| 清镇市| 黎川县| 洛川县| 古蔺县| 彭水| 湘西| 太保市| 枣强县|