Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/04/2014, 07:27
Avatar de temerariomalaga
temerariomalaga
 
Fecha de Ingreso: marzo-2013
Ubicación: Londres
Mensajes: 156
Antigüedad: 11 años, 1 mes
Puntos: 9
Respuesta: Evento onchange en input sin escribir

Cita:
Iniciado por quimfv Ver Mensaje
Debes modificar la función que captura los datos y le pides que ejecute lo mismo que ejecutas en el onchange ya lo tendrás, incluso puedes llamar al evento....


function capturaDatos(......){
.....
document.getElementById("idDelCampo").onchange();
}
No he comprendido muy bien lo de pedirle a la función que ejecute lo mismo que en el onchange.
He probado a capturar el valor con el .onchange pero sigue sin hacer nada. Le he puesto un alert para comprobar que coje la variable pero nunca llega a entrar en la condición.
Dejo aquí como hago la llamada a la función y la función en sí.
Código HTML:
Ver original
  1. <td><input type="text" id="club" value="" onchange="carga()"/></td>
Código Javascript:
Ver original
  1. function carga()
  2. {
  3. var club=document.getElementById("club").onchange();
  4. alert(club);
  5. var xmlhttp;
  6. if (window.XMLHttpRequest){
  7.  
  8. xmlhttp=new XMLHttpRequest();
  9. }
  10. else{
  11.  
  12. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  13. }
  14. xmlhttp.onreadystatechange=function()
  15. {
  16. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  17. {
  18. document.getElementById("pista2").innerHTML=xmlhttp.responseText;
  19. }
  20. }
  21. xmlhttp.open("POST","libpista2.php",true);
  22. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  23. xmlhttp.send("club="+club);
  24. }
__________________
Málaga Club de Fútbol: Memoria, Compromiso, Fe