ASP判断学号是否存在

 js代码(同页) 

 

< script language = javascript >
function  check_user(form) {
u_no
=form.s_no.value;
if (u_no==null||u_no==''){
alert(
"请您输入学号");
return false;
}

infoBoard
=document.getElementById("checkInfo");
infoBoard.innerText
='查询中...';
myurl
="http://192.168.1.6/stu/admin/cuno.asp?u_no="+u_no;
retCode
=openUrl(myurl);
switch(retCode){
case "-2":
infoBoard.innerHTML
='抱歉,查询失败';break;
case "1":
infoBoard.innerHTML
=''+u_no+'可以使用';break;
case "0":
infoBoard.innerHTML
='抱歉,学号'+u_no+'已经被使用';
}

return;
}


function  openUrl(url) {
var objxml=new ActiveXObject("Microsoft.XMLHttp")
objxml.open(
"GET",url,false);
objxml.send();
retInfo
=objxml.responseText;
if (objxml.status=="200"){
return retInfo;
}

else{
return "-2";
}

}

script >

 

文本框代码(同页)

 

< input  type ="text"  name ="s_no"  size ="20"  onblur ="check_user(this.form);" >< span  id ="checkInfo" > span >

 

判断页(cuno.asp)

 

< ! -- #include file = " ../include/conn.asp " -->  
<
u_no
= request.querystring( " u_no "
Set  rs  =  Server.CreateObject ( " ADODB.Recordset "
sql 
=   " Select * from stubasic where s_no=' " & u_no & " ' "  
rs.Open sql,conn,
1 , 1  
if  rs.eof  and  rs.bof  then  
Response.write 
" 1 "
else  
Response.write 
" 0 "
end   if  
rs.close 
set  rs = nothing  
%
>

你可能感兴趣的:(技术文章,asp,function,javascript,user,url,input)