Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need to add a function to an existing script

    I have tried a number of ways and cannot make this work without errors. I have taken an example script that types-ahead a state name in a text box and changed it to type ahead a username on my login form, that works great. What I need to do is to make the password box on the form type ahead enabled as well (with a different list of type-ahead words) - I am stumped as to how to do this.

    Here is the code in my header on the login page and the form, I will attach the autosuggest1 and the suggestions1 form. These work with the username, can anyone help? Thanks:

    <script type="text/javascript" src="autosuggest1.js"></script>
    <script type="text/javascript" src="suggestions1.js"></script>
    <script type="text/javascript">
    window.onload = function () {
    var oTextbox = new AutoSuggestControl(document.getElementById("username"), new StateSuggestions());
    }
    </script>

    FORM


    <form action="FMPro" method="post">
    <tbody>
    <tr>
    <td align=right width="64">Username:</td>
    <td align=left colspan=2 width="211">
    <input type=text name=UserName value="" size=20>
    </td>
    </tr>
    <tr>
    <td align=right width="64">Password:</td>
    <td align=left colspan=2 width="211">
    <input type=text name=Password value="" size=20>
    </td>
    </tr>
    <tr>
    <td align=right valign=top width="64">&nbsp;</td>
    <td align=right colspan=2 width="211">
    <input type=IMAGE src="login.gif" border=0 name="-new">
    <input type="hidden" name="-new" value="search">
    </td>
    </tr>
    </tbody>
    </form>
    Attached Files Attached Files

  • #2
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am not looking for a full solution, just a pointer in the right direction. I have tried duplicating the entire script and adding it to the header as well as duplicating the 2 files - either one or the other will work, but not both fields.

    So then I tried to duplicate just the function and add in a second suggestions file, that produced all kinds of errors.

    I just need a place to start... can anyone shed light?

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    maybe

    have you tried this:
    <script type="text/javascript" src="autosuggest1.js"></script>
    <script type="text/javascript" src="suggestions1.js"></script>
    <script type="text/javascript">
    window.onload = function () {
    var oTextbox = new AutoSuggestControl(document.getElementById("username"), new StateSuggestions());
    }
    </script>

    FORM

    <script type="text/javascript" src="autosuggest1.js"></script>
    <script type="text/javascript" src="suggestions1.js"></script>
    <script type="text/javascript">
    window.onload = function () {
    var oTextbox = new AutoSuggestControl(document.getElementById("username"), new StateSuggestions());
    }
    </script>
    <form action="FMPro" method="post">
    <tbody>
    <tr>
    <td align=right width="64">Username:</td>
    <td align=left colspan=2 width="211">
    <input type=text name=UserName value="" size=20>
    </td>
    </tr>
    <tr>
    <td align=right valign=top width="64">&nbsp;</td>
    <td align=right colspan=2 width="211">
    <input type=IMAGE src="login.gif" border=0 name="-new">
    <input type="hidden" name="-new" value="search">
    </td>
    </tr>
    </tbody>
    </form>
    <script type="text/javascript" src="autosuggest2.js"></script>
    <script type="text/javascript" src="suggestions2.js"></script>
    <script type="text/javascript">
    window.onload = function () {
    var oTextbox = new AutoSuggestControl(document.getElementById("password"), new StateSuggestions());
    }
    </script>
    <form action="FMPro" method="post">
    <tbody>
    <tr>
    <td align=right width="64">Password:</td>
    <td align=left colspan=2 width="211">
    <input type=text name=Password value="" size=20>
    </td>
    </tr>
    <tr>
    <td align=right valign=top width="64">&nbsp;</td>
    <td align=right colspan=2 width="211">
    <input type=IMAGE src="login.gif" border=0 name="-new">
    <input type="hidden" name="-new" value="search">
    </td>
    </tr>
    </tbody>
    </form>
    just a suggestion.

  • #4
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have tried a few variations of trying to get both scripts on one page, but no luck - dividing them into two forms would cause two records to be created (the form submits to a database), so that won't work. I have tried to combine both functions auto1 and auto2, but either one works (username) or the other (password) - I know there must be a way to add type-ahead to a second field, but doggone if I know what it is


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •