Link to home
Create AccountLog in
Avatar of cseink
cseink

asked on

disable or hide form field with ajax

I have a web form with a texfield called getkey. I want to disable some other form fields until the correct 3 digit code is entered.  See code below.   If it's a match then undisable the form fields else disable them. I was also thinking maybe put the forms fields in a div then do a show hide. Not sure the best way to do this.
<script type="text/javascript">
function showHint(str)
{
var xmlhttp;
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","loadkey.asp?getkey="+str,true);
xmlhttp.send();
}
</script>

asp behind
Set Rs = Server.CreateObject("ADODB.Recordset") 


key=request.QueryString("getkey")

SQL2="SELECT * FROM tbl_reviewers where logonnumber=" & key &""

 Rs.Open sql2, Conn
if NOT Rs.EOF then 	

'undisable form fields

ELSE
'disable form fields
end if
rs.close

%>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer