Jquery Autocomplete
-
Hi, I have a dropdown list populated with the list of names on my aspx page. I want to use this as a data source for autocomplete in the name textbox. Which is the best way to do it in jquery?! Thanks,
-
Hi, I have a dropdown list populated with the list of names on my aspx page. I want to use this as a data source for autocomplete in the name textbox. Which is the best way to do it in jquery?! Thanks,
The best way is to read the documentation http://docs.jquery.com/Plugins/autocomplete[^]
I know the language. I've read a book. - _Madmatt
-
The best way is to read the documentation http://docs.jquery.com/Plugins/autocomplete[^]
I know the language. I've read a book. - _Madmatt
I 've tried the following:
<script type ="text/javascript">
$(document).ready(function() {
var a = $("input#names").val();$("#tags").autocomplete({ url: "CodeFile1.cs\\SearchNames", data: $("input#names").val() }); }); </script>
<div class="ui-widget">
<label for="names">Names: </label>
<input id="names" />
</div>and my codefile is :
public string[] SearchNames(string Name)
{
string [] Names = null;
int i;
i = 0;
ServiceClient serviceClient = new ServiceClient();
SearchResponse searchResponse = new SearchResponse();
principalSearchResponse = bondInformationServiceClient.SearchPrincipals(principalSearchRequest);foreach (Name name in SearchResponse.NameList) { Names \[i\] = name .nameField.ToString().Trim(); i++; } } return Names ; }
gives me an runtime error: object expected.
-
I 've tried the following:
<script type ="text/javascript">
$(document).ready(function() {
var a = $("input#names").val();$("#tags").autocomplete({ url: "CodeFile1.cs\\SearchNames", data: $("input#names").val() }); }); </script>
<div class="ui-widget">
<label for="names">Names: </label>
<input id="names" />
</div>and my codefile is :
public string[] SearchNames(string Name)
{
string [] Names = null;
int i;
i = 0;
ServiceClient serviceClient = new ServiceClient();
SearchResponse searchResponse = new SearchResponse();
principalSearchResponse = bondInformationServiceClient.SearchPrincipals(principalSearchRequest);foreach (Name name in SearchResponse.NameList) { Names \[i\] = name .nameField.ToString().Trim(); i++; } } return Names ; }
gives me an runtime error: object expected.
I think you read the documentation on the autocomplete plugin wrong. If you wish to use an Url to load the autocomplete data from, which for as far as I've been able to figure out by your sample code you are, then you should return a plain text response with one possible word per line. And keep in mind it performs a round trip to the server, which means you will need to create a script file on the server (JSP, PHP, ASPX). Look at http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions[^] The documentation indicates the call to the server will contain the word to autocomplete in a parameter called 'q'.
-
I think you read the documentation on the autocomplete plugin wrong. If you wish to use an Url to load the autocomplete data from, which for as far as I've been able to figure out by your sample code you are, then you should return a plain text response with one possible word per line. And keep in mind it performs a round trip to the server, which means you will need to create a script file on the server (JSP, PHP, ASPX). Look at http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions[^] The documentation indicates the call to the server will contain the word to autocomplete in a parameter called 'q'.
Thanks Gerben, I read it again and understood what u mean!!.. I was just wondering if it's possible to use a wcf with it? Also since this wcf is being used extensively and returns an object which is a list thanks,