Tema: Suggest
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/04/2008, 01:41
FlashO
 
Fecha de Ingreso: marzo-2008
Mensajes: 42
Antigüedad: 16 años, 7 meses
Puntos: 0
Suggest

Hola he descargado un ejemplo de Ajax para autocompletar una caja de texto.
Lo que quisiera es que el ejemplo leyerá de mi base de datos sql, y no de lo especificado en el código:

Código:
<SCRIPT type=text/javascript>
function findValue(li) {
if( li == null ) return alert("No match!");

// if coming from an AJAX call, let's use the CityId as the value
if( !!li.extra ) var sValue = li.extra[0];

// otherwise, let's just display the value in the text box
else var sValue = li.selectValue;

alert("The value you selected was: " + sValue);
}

function selectItem(li) {
findValue(li);
}

function formatItem(row) {
return row[0] + " (id: " + row[1] + ")";
}

function lookupAjax(){
var oSuggest = $("#CityAjax")[0].autocompleter;

oSuggest.findValue();

return false;
}

function lookupLocal(){
var oSuggest = $("#CityLocal")[0].autocompleter;

oSuggest.findValue();

return false;
}



$("#CityLocal").autocompleteArray(
[
"Aberdeen", "Ada", "Adamsville", "Addyston", "Adelphi", "Adena", "Adrian", "Akron",
"Albany", "Alexandria", "Alger", "Alledonia", "Alliance", "Alpha", "Alvada",
"Alvordton", "Amanda", "Amelia", "Amesville", "Amherst", "Amlin", "Amsden",
"Amsterdam", "Andover", "Anna", "Ansonia", "Antwerp", "Apple Creek", "Arcadia",
"Arcanum", "Archbold", "Arlington", "Ashland", "Ashley", "Ashtabula", "Ashville",
"Athens", "Attica", "Atwater", "Augusta", "Aurora", "Austinburg", "Ava", "Avon",
"Avon Lake", "Bainbridge", "Bakersville", "Baltic", "Baltimore", "Bannock",
"Barberton", "Barlow", "Barnesville", "Bartlett", "Barton", "Bascom", "Batavia",
"Bath", "Bay Village", "Beach City", "Beachwood", "Beallsville", "Beaver",
"Beaverdam", "Bedford", "Bellaire", "Bellbrook", "Belle Center", "Belle Valley",
"Bellefontaine", "Bellevue", "Bellville", "Belmont", "Belmore", "Beloit", "Belpre",
"Benton Ridge", "Bentonville", "Berea", "Bergholz", "Berkey", "Berlin",
"Berlin Center", "Berlin Heights", "Bethel", "Bethesda", "Bettsville", "Beverly",
"Bidwell", "Big Prairie", "Birmingham", "Blacklick", "Bladensburg", "Blaine",
"Blakeslee", "Blanchester", "Blissfield", "Bloomdale", "Bloomingburg",
"Bloomingdale"
{
delay:10,
minChars:1,
matchSubset:1,
onItemSelect:selectItem,
onFindValue:findValue,
autoFill:true,
maxItemsToShow:10
}
);
});
</SCRIPT>
Alguien me puede ayudar ??
Muchas gracias