views:

28

answers:

1

Hi all, I am trying to get AutoComplete to work on a website application I am making. I have stripped my code down to the bare essentials and I still cannot get it to work. I got the source file from http://www.phpguru.org/static/AutoComplete.html and I have done my best to implement it exactly how they did on their website demo. My test code is below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;

    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>test</title>
    </head>

    <body>

        <script language="javascript" type="text/javascript" src="/Management/AutoComplete.js"></script>

        <div id="content">  

            <script type="text/javascript">

                if (location.href.indexOf('/JavaScripts/AutoComplete') != -1) {

                    window.onload = function(){

                        data = ['Joes Plumbing1','Joes Plumbing2','Joes Plumbing3','Joes Plumbing4'].sort();    

                        AutoComplete_Create('customers', data);

                    }

                }

            </script>

            <form id="form" action="" method="post">

                <table border="0">

                    <tr>
                        <td>Customer Search</td>
                    </tr>

                    <tr>
                        <td><input type="text" id="customers"/></td>
                    </tr>

                </table>

            </form>

        </div>

    </body>

</html>

Here is a bit more back ground info that may help you help me:

My server works fine with other .js files.

I copied and pasted the AutoComplete.js (NOT AutoComplete.old.js) file I downloaded from the site mentioned above, and didn't touch it at all.

Why isn't this working?

A: 

@Goran answered my question correctly in his comment to my question so props to him. The problem was my if statement:

if (location.href.indexOf('/JavaScripts/AutoComplete') != -1)

Once I made the string /JavaScripts/AutoComplete match what was in my address bar everything worked fine!

typoknig