Ajax+asp Application Example Registration module, form submission _ Application Tips

Source: Internet
Author: User
<!--registration Module-->default.asp
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>Ajax-Sample1</title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>//Please make sure the encoding of this page is set to UTF-8, otherwise there will be garbled
<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>
<body>
<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= "register" onclick= "Check ()"/>
To highlight no refresh effect, the server-side program will automatically perform the million addition operation
</body>

Copy Code code as follows:

<!----form data submission Script--->reg. Js
function GE (a) {return document.getElementById (a);}
function Check () {
if (GE (' Regid '). value== ') {ge (' msg '). innerhtml= ' id cannot be empty '; return false}
if (GE (' Regpassword '). value== ') {ge (' msg '). innerhtml= ' password cannot be empty '; 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= "Submitting data ..."}
};
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= ' Your browser does not support XMLHttpRequest '
}
}

<!---process--->reg.asp
Copy Code code as follows:

<%@ language= "VBSCRIPT" codepage= "65001"%>//codepage must be 650001, Otherwise, there will be garbled, if there is HTML text, it must be set to UTF-8 encoding, otherwise it would appear garbled.
<%
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 and password must be filled in"
Else
If regid <> "Tony" then
Str = ' registered successfully, ID ' & regid & ', password is ' & regpassword&f
Else
str = ' registration failed, ID already exists '
End If
En D If
Response.Write "GE (' msg '). Innerhtml= '" & Str & "; GE (' Regsubmit '). Disabled=false "
Response.End
%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.