<input type="text" name="txtn1" id="txt1" .....................
CODE:
<%@ Page Language="C#" AutoEventWireup="true" %>
<!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 runat="server">
<title></title>
<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","ajaxresponse.aspx?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<h3>Start typing a name in the input field below:</h3>
<form id="form1" action="">
First name: <input type="text" name="txtn1" id="txt1" onkeyup="showHint(this.value)" />
<p>Suggestions: <span id="txtHint"></span></p>
</form>
server file CODE
<%@ Page Language="C#" AutoEventWireup="true" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Response.Expires=-1;
string[] a = new string[30];
//Fill up array with names
a[1]="Anna";
a[2]="Brittany";
a[3]="Cinderella";
//get the q parameter from URL
string q=Request.QueryString["q"];
q=q.ToUpper();
string hint="";
//lookup all hints from array if length of q>0
if (q.Length>0)
{
for (int i=1;i<30;i++)
{/*
if(q=ucase(mid(a[i].,1,len(q))) then
if hint="" then
hint=a(i)
else
hint=hint & " , " & a(i)
end if
end if
*/
}
}
hint=a[1];
//'Output "no suggestion" if no hint were found
//'or output the correct values
if (hint == "")
Response.Write("no suggestion");
else
Response.Write(hint);
%>
</div>
</form>
</body>
</html>
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE