Retroceder   Foros del Web > Programación para sitios web > AJAX

Respuesta
 
Herramientas Desplegado
Antiguo 23-abr-2008, 01:41   #1 (permalink)
FlashO ha deshabilitado el karma
 
Fecha de Ingreso: marzo-2008
Mensajes: 27
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
FlashO está desconectado   Responder Citando
Antiguo 23-abr-2008, 09:07   #2 (permalink)
$this->role('moderador');
GatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradable
 
Avatar de GatorV
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ags/
Mensajes: 13.916
Re: Suggest

Mmm ¿cual es tu problema? o ¿deseas que alguien te haga el código para que solo tu lo pegues?

Saludos.
__________________
Blog Web
GatorV está desconectado   Responder Citando
Antiguo 19-sep-2008, 00:19   #3 (permalink)
mp3man ha deshabilitado el karma
 
Fecha de Ingreso: junio-2008
Mensajes: 7
Respuesta: Suggest

Buenas,
la idea es que realices una llamada síncrona, sobretodo que sea síncrona a un archivo php o lo que sea que devuelva por ejemplo un xml con toda la información de la lista, para luego añadirlo a una variable global de javascript en el responseXml o responseText del objeto XmlHttpRequest. Luego puedes hacer lo que quieras con esa variable, transformarla a un array para añadirlo al elemento de tu capa.
Ojo que con Firefox debido a un bug no funcionan las llamadas síncronas, simplemente no hace nada.
mp3man está desconectado   Responder Citando
Respuesta

No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 06:57.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93