日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

ASP 投票系统所用技术小结

發布時間:2025/4/5 windows 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ASP 投票系统所用技术小结 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Code


Code
5:函數部分應用

<%
titleid
=request.QueryString("titleid")
call?isid(titleid)
set?temp=conn.execute("select?count(id)?from?[VoteTitle]?where?id="&titleid)
if?temp(0)=0?then
????
Call?ShowError("錯誤!")
end?if
Call?RsName(rs,"select?a.id,a.selectitem,a.votecount,b.votetitle,b.webname?from?[VoteSelect]?a?inner?join?[VoteTitle]?b?on?a.titleid=b.id?where?a.titleid="&titleid,1,1)
dim?total
total
=0
do?while?not?rs.eof
total
=total+rs(2)
rs.movenext
loop
rs.movefirst
if?total=0?then
Call?ShowErrorClose("尚無人投票!")
end?if
%>

<a?href="javascript:window.close()">關閉窗口</a>


<%
id
=Cint(request.QueryString("id"))
if?request.QueryString("action")="title"?then
conn.execute(
"delete?from?[VoteSelect]?where?titleid="&id)
conn.execute(
"delete?from?[VoteTitle]?where?id="&id)
end?if
if?request.QueryString("action")="select"?then
conn.execute(
"delete?from?[VoteSelect]?where?id="&id)
end?if
Call?ShowErrorTo("操作成功!","MyVote.asp")
Call?CloseConn()
%>


Code
1:函數頁面:
?
<%
'L.C.H-001建立連接數據庫記錄
Function?RsName(Rs_Name,Sql,A,B)
Set?Rs_Name=Server.CreateObject("Adodb.RecordSet")
Rs_Name.open?Sql,conn,A,B
End?Function
'************************************************************************
'
L.C.H-002釋放記錄集
Sub?CloseRs()
rs.close
set?rs=nothing
End?Sub
'************************************************************************
'
L.C.H-003釋放conn
Sub?CloseConn()
conn.close
set?conn=nothing
End?Sub
'************************************************************************
'
L.C.H-004顯示錯誤提示且返回上一頁
Function?ShowError(a)
response.write(
"<script?language=javascript>alert('"&a&"');javascript:history.go(-1)")
response.write(
"</script>")
response.end()
End?Function
'************************************************************************
'
L.C.H-005顯示錯誤提示且重新載入另一頁
Function?ShowErrorTo(a,b)
response.write(
"<script?language=javascript>alert('"&a&"');")
response.write(
"this.location.href='"&b&"';</script>")
response.end()
End?Function
'************************************************************************
'
L.C.H-006顯示錯誤提示且關閉該窗口
Function?ShowErrorClose(a)
response.write(
"<script?language=javascript>alert('"&a&"');")
response.write(
"javascript:window.close();</script>")
response.end()
End?Function
'************************************************************************
'
L.C.H-007分頁調用
Function?PageGo(sql)
response.write?
"<table?width='99%'?border='1'?align='center'?cellPadding='0'?cellSpacing='0'?bordercolor='#71CC71'?bgcolor='#E9F8E9'?class='12'>"
response.write?
"<form?method=Post?action='"&Myself&"?"&sql&"'>"
response.write?
"<tr><td?height='24'?bordercolor='#E9F8E9'><div?align='center'>"
???
If?currentpage?>?1?Then
??????response.write?
"<a?href='"&Myself&"?"&sql&"page="+cstr(1)+"'><font?color='#ff0000'>首頁</font></a><font?color='#333333'><b>-</b></font>"??
??????Response.write?
"<a?href='"&Myself&"?"&sql&"page="+Cstr(currentpage-1)+"'><font?color='#ff0000'>前頁</font></a><font?color='#333333'><b>-</b></font>"
???
Else
??????Response.write?
"<font?color='#333333'>首頁-</font>"
??????Response.write?
"<font?color='#333333'>前頁-</font>"??????
???
End?if
???
If?currentpage?<?rs.PageCount?Then
??????Response.write?
"<a?href='"&Myself&"?"&sql&"page="+Cstr(currentPage+1)+"'><font?color='#ff0000'>后頁</font></a><font?color='#333333'><b>-</b></font>"
??????Response.write?
"<a?href='"&Myself&"?"&sql&"page="+Cstr(rs.PageCount)+"'><font?color='#ff0000'>尾頁</font></a>&nbsp;&nbsp;"
???
Else
??????Response.write?
"<font?color='#333333'>后頁-</font>"
??????Response.write?
"<font?color='#333333'>尾頁</font>&nbsp;&nbsp;"???????
???
End?if
Response.write?
"<font?color='#333333'>頁次:</font>"?&?"<font?color=#ff0000?face='Geneva,?Arial,?Helvetica,?sans-serif'>"?&?Cstr(CurrentPage)?&??"</font>"?&?"<font?color='#333333'?face='Geneva,?Arial,?Helvetica,?sans-serif'>/"?&?Cstr(rs.pagecount)?&?"</font>&nbsp;"
Response.write?
"<font?color=#ff0000?face='Geneva,?Arial,?Helvetica,?sans-serif'>"?&?Cstr(MaxPerPage)?&?"</font>"?&?"<font?color='#333333'?face='Geneva,?Arial,?Helvetica,?sans-serif'>條/頁&nbsp"?&?"共</font>"?&?"<font?color=#ff0000?face='Geneva,?Arial,?Helvetica,?sans-serif'>"?&?Cstr(rs.RecordCount)?&?"</font>"?&?"<font?color='#333333'>條信息</font>&nbsp;&nbsp;"
response.write?
"<font?color='#333333'>轉到:</font><input?type='text'?name='page'?size=4?maxlength=4?class='Input'?value="&Currentpage&">&nbsp;"
response.write?
"<input?type='submit'??value='轉到'??name='cndok'?class='button'></span>&nbsp;&nbsp;"???
response.write?
"</div></td></tr></form></table>"
End?Function
'************************************************************************
'
L.C.H-008禁止外部提交
Sub?Remote()
if?not?(instr(1,Request.ServerVariables("http_Referer"),Request.ServerVariables?("SERVER_NAME"),1)=8)?then
????
Call?ShowError("參數錯誤!")
end?if?
end?Sub
'************************************************************************
'
L.C.H-010是否為數字
Function?IsDigit(a)
????
if?isnumeric(a)=false?then
????????
Call?ShowError("參數錯誤!")
????
end?if
end?Function
'************************************************************************
'
L.C.H-011傳遞ID的有效性
Function?Isid(a)
????
if?a=""?or?isnumeric(a)=false?then
????????
Call?ShowError("參數錯誤!")
????
end?if
end?Function
'************************************************************************
'
L.C.H-012關閉當前彈出窗口,并且刷新父窗口
Sub?Refresh()
????response.write(
"<script?language='javascript'>")
????response.write(
"alert('操作成功!');")
????response.write(
"opener.location.reload();")
????response.write(
"top.close();")
????response.write(
"</script>")
????response.end()
end?sub?
'************************************************************************
'
L.C.H-013打開彈出窗口,并且刷新父窗口
Sub?Refresh2()
????response.write(
"<script?language='javascript'>")
????response.write(
"opener.location.reload();")
????response.write(
"</script>")
end?sub?
'************************************************************************
%>

2:asp中Response.Expires?=?-1
一般情況下,當用戶請求WEB服務器時,服務器把請求回復給客戶端。在客戶端,瀏覽器把緩存作為一種加快速度的策略,就是當請求時先檢查緩存的情況,如果有就直接調緩存了,而不請求服務器了。?
在WEB程序設計中,有時為了防止重復的提交或者嚴格的次序等,必須讓用戶的數據立即在使用后就過期,當用戶后退時就顯示過期而不能繼續使用。也算是為安全考慮的吧。?
一般,response.expires寫在頁面的最上端,后面跟的是一個時間,就是過期的時間,0表示立即過期。
response.expires=1表示在1分鐘后過期。


3:ASP的Round函數是4舍6入,5奇進偶不進
[
round(56.5)=56?
但?
round(57.5)=58?
]
ASP的Round函數是4舍6入,5奇進偶不進,這樣在一大堆需要四舍五入的數字相加時,可以減少誤差增加精度,很多語言的round函數都是這樣定義的。?
56.5,小數5前是6,偶數,因此不進,舍為56。如果一定需要四舍五入的話,用類似int(n+0.5)的方法。
4:進度條,并顯示百分比
?
<td?bgcolor="#FFFFFF"><div?align="left">&nbsp;<img?src=?image/vote.gif?width=<%=int((rs(2)/total)*100)%>?height=9><font?face="Geneva,?Arial,?Helvetica,?sans-serif">&nbsp;<%=round(rs(2)/total*100,2)%>%</font></div></td>
5:復制代碼的JS
<SCRIPT?language=JavaScript>
<!--

function?MM_goToURL()?{?//v3.0
??var?i,?args=MM_goToURL.arguments;?document.MM_returnValue?=?false;
??
for?(i=0;?i<(args.length-1);?i+=2)?eval(args[i]+".location='"+args[i+1]+"'");
}
function?JM_cc(ob){
var?obj=MM_findObj(ob);?if?(obj)?{?
obj.select();js
=obj.createTextRange();js.execCommand("Copy");}
alert(
"復制成功!")
}

function?MM_findObj(n,?d)?{?//v4.0
??var?p,i,x;??if(!d)?d=document;?if((p=n.indexOf("?"))>0&&parent.frames.length)?{
????d
=parent.frames[n.substring(p+1)].document;?n=n.substring(0,p);}
??
if(!(x=d[n])&&d.all)?x=d.all[n];?for?(i=0;!x&&i<d.forms.length;i++)?x=d.forms[i][n];
??
for(i=0;!x&&d.layers&&i<d.layers.length;i++)?x=MM_findObj(n,d.layers[i].document);
??
if(!x?&&?document.getElementById)?x=document.getElementById(n);?return?x;
}
//-->
</SCRIPT>

調用時:
<input?name="Button"?type="button"?class="button"?value="點擊復制代碼"?onClick="JM_cc('js_1')">
js_1為一個
<textarea?
<textarea?cols="80"?rows="8"?class="input1"?name="js_1"?wrap=VIRTUAL><iframe?border="0"?marginwidth="0"?scrolling="No"?marginheight="0"?src="您網站的絕對地址/Vote/?id=<%=request("id")%>"?width="200"?height="200"?frameborder="no"></iframe></textarea>

轉載于:https://www.cnblogs.com/xocom/articles/asp.html

總結

以上是生活随笔為你收集整理的ASP 投票系统所用技术小结的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。