国产探花免费观看_亚洲丰满少妇自慰呻吟_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

分享:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 济阳县| 洪江市| 黎川县| 广丰县| 湘潭县| 龙南县| 兰西县| 交口县| 彰化县| 高要市| 宁晋县| 内黄县| 定边县| 灵石县| 衡山县| 颍上县| 漳州市| 江永县| 南城县| 兖州市| 巴青县| 隆安县| 永春县| 宿松县| 梧州市| 伊宁县| 本溪市| 通山县| 彰化市| 穆棱市| 长葛市| 彭阳县| 于都县| 武川县| 汤原县| 中江县| 龙胜| 松原市| 平阳县| 东乌珠穆沁旗| 金乡县|