Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/04/2011, 02:36
Avatar de historiasdemaria
historiasdemaria
 
Fecha de Ingreso: septiembre-2010
Ubicación: www
Mensajes: 433
Antigüedad: 13 años, 7 meses
Puntos: 54
Respuesta: Symfony autocompletado jquery

Buenas,

Yo tengo un caso asi, un autocomplete, en el html hay:

Código HTML:
Ver original
  1. <input size="30" id="inputString" name="inputString" onkeyup="lookup(this.value);" onblur="fill();" autocomplete="off" type="text">
  2.  
  3. <div class="suggestionsBox" id="suggestions" style="display: none;">
  4.     <div class="suggestionList" id="autoSuggestionsList">&nbsp;
  5.     </div>
  6.  
  7. Y luego estas dos funciones en el javascript de la pagina:
  8.  
  9.  
  10. function lookup(inputString) {
  11. if(inputString.length == 0) {
  12. // Hide the suggestion box.
  13. $('#suggestions').hide();
  14. } else {
  15. $.post("my_module/my_index", {queryString: ""+inputString+""}, function(data){
  16. if(data.length >0) {
  17. $('#suggestions').show();
  18. $('#autoSuggestionsList').html(data);
  19. }
  20. });
  21. }
  22. } // lookup
  23. function fill(thisValue) {
  24. $('#inputString').val(thisValue);
  25. setTimeout("$('#suggestions').hide();", 200);
  26. }



En my_module/my_index hay un script que hace la query a la base de datos, ahi tu lo puedes hacer con Doctrine..