Ajax+asp應用執行個體 註冊模組,表單提交

來源:互聯網
上載者:User

<!--註冊模組-->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+'&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編碼,否則將出現亂碼.
<%
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
str = "ID和PASSWORD必須填寫"
Else
If regid <> "tony" Then
str = "註冊成功,ID為" & regid & " , 密碼為" & regpassword&f
Else
str = "註冊失敗,ID已經存在"
End If
End if
Response.Write "GE('msg').innerHTML='" & str & "';GE('regsubmit').disabled=false"
Response.End
%>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.