加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

Ajax+asp应用的例子中, 注册模块,表单提交

发布时间:2023-11-13 10:59:26 所属栏目:Asp教程 来源:
导读:<!--注册模块-->default.asp
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.or
<!--注册模块-->default.asp
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax - Sample1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> //请一定要将此页的编码设为UTF-8,否则将出现乱码
<meta name="author" content="tonyhl[at]126.com" />
<meta http-equiv="pragma" content="no-cache"/>
<script language="javascript" type="text/javascript" src="reg.js"></script>
<link rel="stylesheet" href="css.css" type="text/css" media="all"/>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 409px;
top: 88px;
}
-->
</style>
</head>
<body>
<h2>Ajax应用实例: 注册模块</h2>
<div id="Layer1">
<div id="msg"></div>
</div>
ID: <input type="text" id="regid" />
Password: <input type="password" id="regpassword" />
<input name="f" type="file" />
<input type="submit" id="regsubmit" value="注册" onclick="Check()" />
<h2>当注册ID为 tony的用户时,后台验证该ID已存在,返回提示信息<br />
为突出显示无刷新效果,服务器端程序将自动进行百万加法运算
</h2>
</body>
</html>

复制代码 代码如下:
<!----表单数据提交脚本--->REG.JS
function GE(a){return document.getElementById(a);}
function Check(){
if(GE('regid').value==''){GE('msg').innerHTML='ID不能为空';return false}
if(GE('regpassword').value==''){GE('msg').innerHTML='password 不能为空';return false}
var X=new ActiveXObject("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');
var SendData = 'regid='+GE('regid').value+'®password='+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编码,否则将出现乱码.
<%
Dim regid, regpassword, str
regid=Request.Form("regid")
regpassword=Request.Form("regpassword")
f=Request.Form("file")
Dim i, ii
ii = 0
For i = 0 To 1000000
ii = ii + i
Next
If regid="" or regpassword="" then

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章