...

View Full Version : Need to add a function to an existing script



laural4705
06-27-2006, 09:36 PM
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>

laural4705
06-28-2006, 12:31 AM
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?

Chozin
06-28-2006, 12:43 PM
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.

laural4705
06-28-2006, 02:54 PM
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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum