|
|
 Prize winner in Competition
"Best ASP.NET article of Jul 2007"
Comments and Discussions
|
|
 |

|
I've got auto-suggest working perfectly. It's great. I can use multiple text fields without any problems, except when I put the field within a form.
This is test code that works for the built-in array and for server side auto-suggest. Works perfectly in both cases.
When I had this working, I'd thought that I would have no problems getting this into real code.
<html>
<head>
<link rel="stylesheet" type="text/css" href="autosuggest.css"></link>
<script type='text/javascript' src='autosuggest.js'></script>
<script>
var customarray = ["apple", "alligator", "banana", "elephant",
"pear", "kingbird", "kingbolt", "kingcraft",
"kingcup", "kingdom", "kingfisher" ];
</script>
</head>
<body>
<input type="text"
id="tb" value=""
style="font-family:verdana;width:300px;font-size:12px" />
<script>
var obj = new autosuggest("tb", customarray);
</script>
<input type="text" id="tb2" value="" style="font-family:verdana;width:300px;font-size:16px" />
<script>
var obj = new autosuggest("tb2", "", "http://127.0.0.1/autosuggest.wsgi/?field=npi&s=");
</script>
</body>
</html>
For whatever reason, auto-suggest is not reading in the strings from the fields when it's in a form.
<form id="subForm" name="subForm" method="post" onSubmit="return verifyForm(this);" action="http://127.0.0.1/retrieve.wsgi">
<div class="box">
<h2>Store information</h2>
<p>
<label class="label">NPI#</label><input type="text" name="npi" id="npi" />
<script type="text/javascript">
var obj = new autosuggest("npi", "", "http://127.0.0.1/autosuggest.wsgi/?field=npi&s=");
</script>
</p>
I've tried changed the ids passed to autocomplete but that didn't work. I followed the code using Firebug and I can see that the code isn't failing but it's not finding the text from the field.
On about line 35, I can see that the correct field id is being assigned.
function autosuggest(id, array, url, onSelect)
{
var field = document.getElementById(id);
The form actually contains about 15 fields. Rather than having the users guess what might data might actually be present in the database for that field, I'd like to present the most likely data first.
I'd greatly appreciate any assistance or guidance you can provide.
Thank you.
modified on Saturday, December 4, 2010 1:42 PM
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
This article presents code that augments any INPUT box with an auto-suggest feature, AJAX-capable
| Type | Article |
| Licence | Zlib |
| First Posted | 24 Aug 2007 |
| Views | 370,481 |
| Downloads | 1,753 |
| Bookmarked | 197 times |
|
|