Hi all,

I am new to ajax. I was trying to run an example but i am not able to
get the values to the calling page.
I am attaching the snippet of code I have written:
<html xmlns="http://www.w3.org/1999/xhtml"; >
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
        function showHint(str)
        {
            if (str.length == 0)
            {
                documeny.getElementById("txtHint").innerHTML = ""
                return
            }
            xmlHttp = GetXmlHttpObject()
            if (xmlHttp == null)
            {
                alert("Browser doesn't support HTTP Request");
                return
            }
            var url = "GetHint.aspx"
            url = url + "?q=" + str
            url = url + "&sid=" + Math.random()
            alert(url)
            xmlHttp.onreadystatechange =stateChanged
            xmlHttp.open("GET",url,true)
            xmlHttp.send(null)

        }
        function stateChanged()
        {
            if ((xmlHttp.readyState == 4) || (xmlHttp.readyState ==
"completed"))
            {

                document.getElementById("txtHint").innerHTML =
xmlHttp.resposeText
            }
        }
        function GetXmlHttpObject()
        {
            var objXMLHttp = null
            if (window.XMLHttpRequest)
            {
                objXMLHttp = new XMLHttpRequest()
            }
            else if(window.ActiveXObject)
            {
                objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
            }
            return objXMLHttp;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        First Name: <input type="text" id="txt1"
onkeyup="showHint(this.value)" />
    </div>
    </form>
    <p>Suggestions: <span id="txtHint"></span></p>
</body>
</html>

In the called page I am writing the code like this

    protected void Page_Load(object sender, EventArgs e)
    {
        string[] arr;
        arr = new string[30];
        // Fill up the array
        arr[1] = "Anna";
        arr[2] = "Brittany";
        arr[3] = "Cinderella";
        arr[4] = "Diana";
        arr[5] = "Eva";
        arr[6] = "Fiona";
        arr[7] = "Gunda";
        arr[8] = "Hege";
        arr[9] = "Inga";
        arr[10] = "Johanna";
        arr[11] = "Kitty";
        arr[12] = "Linda";
        arr[13] = "Nina";
        arr[14] = "Ophelia";
        arr[15] = "Petunia";
        arr[16] = "Amanda";
        arr[17] = "Raquel";
        arr[18] = "Cindy";
        arr[19] = "Doris";
        arr[20] = "Eve";
        arr[21] = "Evita";
        arr[22] = "Sunniva";
        arr[23] = "Tove";
        arr[24] = "Unni";
        arr[25] = "Violet";
        arr[26] = "Liza";
        arr[27] = "Elizabeth";
        arr[28] = "Ellen";
        arr[29] = "Wenche";
        arr[30] = "Vicky";
        // Get the q parameter from URL
        string q = Request.QueryString["q"].ToUpper();
        string hint = string.Empty;
        // Look up all hints from array if length of q > 0
        if (q.Length > 0)
        {
            for (int i = 1; i <= 30; i++)
            {
                if (q == (arr[i].Substring(1, q.Length)).ToUpper())
                {
                    if (hint == "")
                    {
                        hint = arr[i];
                    }
                    else
                    {
                        hint = hint + " , " + arr[i];
                    }
                }
            }
        }

        // Output "no suggestion" if no hint where found
        // or output the correct values
        if (hint == "")
        {
            Response.Write("no suggestion");
        }
        else
        {
            Response.Write(hint);
        }
    }

It may sound foolish for asking such simple question but I am really
astounded by capabilities of AJAX.
Please let me know what is the mistake that I am making.

Regards
Deepak Sinha


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to