Ajax+asp应用实例: 注册模块,表单提交

<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&amp;dt=1225678105875&amp;lmt=1219829521&amp;prev_slotnames=1891601125&amp;output=html&amp;slotname=3685991503&amp;correlator=1225678105234&amp;url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1435.html&amp;ea=0&amp;ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__71.html&amp;frm=0&amp;ga_vid=794657364.1225360561&amp;ga_sid=1225676616&amp;ga_hid=2054030497&amp;ga_fc=true&amp;flash=9.0.124.0&amp;u_h=768&amp;u_w=1024&amp;u_ah=715&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480&amp;u_java=true" frameborder="0" width="300" scrolling="no" height="250" allowtransparency></iframe>
<!--注册模块-->default.asp

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax-Sample1</title>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>//请一定要将此页的编码设为UTF-8,否则将出现乱码
<metaname="author"content="tonyhl[at]126.com"/>
<metahttp-equiv="pragma"content="no-cache"/>
<scriptlanguage="javascript"type="text/javascript"src="reg.js"></script>
<linkrel="stylesheet"href="css.css"type="text/css"media="all"/>
<styletype="text/css">
<!--
#Layer1{
position:absolute;
width:200px;
height:115px;
z-index:1;
left:409px;
top:88px;
}
-->
</style>
</head>
<body>
<h2>Ajax应用实例:注册模块</h2>
<divid="Layer1">
<divid="msg"></div>
</div>
ID:<inputtype="text"id="regid"/>
Password:<inputtype="password"id="regpassword"/>
<inputname="f"type="file"/>
<inputtype="submit"id="regsubmit"value="注册"οnclick="Check()"/>
<h2>当注册ID为tony的用户时,后台验证该ID已存在,返回提示信息<br/>
为突出显示无刷新效果,服务器端程序将自动进行百万加法运算
</h2>
</body>
</html>

<!----表单数据提交脚本--->REG.JS

functionGE(a){returndocument.getElementById(a);}
functionCheck(){
if(GE('regid').value==''){GE('msg').innerHTML='ID不能为空';returnfalse}
if(GE('regpassword').value==''){GE('msg').innerHTML='password不能为空';returnfalse}
varX=newActiveXObject("Msxml2.XMLHTTP");
if(X){
GE('regsubmit').disabled=true;
X.onreadystatechange=function(){
if(X.readyState==4){
if(X.status==200){
eval(X.responseText)
}
else{GE('msg').innerHTML=X.statusText}
}
else{GE('msg').innerHTML="正在提交数据..."}
};
X.open('POST','reg.asp',true);
X.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
varSendData='regid='+GE('regid').value+'&regpassword='+GE('regpassword').value+'&file='+GE('f').value
X.send(SendData)
}
else{
GE('msg').innerHTML='你的浏览器不支持XMLHttpRequest'
}
}



<!---程序处理--->reg.asp

<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%>//CODEPAGE必须为650001,否则也出现乱码,如果有HTML文字,一定设为UTF-8编码,否则将出现乱码.
<%
Dimregid,regpassword,str
regid=Request.Form("regid")
regpassword=Request.Form("regpassword")
f=Request.Form("file")
Dimi,ii
ii=0
Fori=0To1000000
ii=ii+i
Next
Ifregid=""orregpassword=""then
str="ID和PASSWORD必须填写"
Else
Ifregid<>"tony"Then
str="注册成功,ID为"&regid&",密码为"&regpassword&f
Else
str="注册失败,ID已经存在"
EndIf
Endif
Response.Write"GE('msg').innerHTML='"&str&"';GE('regsubmit').disabled=false"
Response.End
%>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值