Ver Mensaje Individual
  #4 (permalink)  
Antiguo 11/04/2011, 15:26
Avatar de edgwin
edgwin
 
Fecha de Ingreso: abril-2011
Ubicación: Guadalajara, Jalisco, Mexico
Mensajes: 47
Antigüedad: 13 años
Puntos: 1
Respuesta: Asignar responseText a una variable. (RESUELTO)

Lo resolvi, deje el codigo de index.php de la siguiente manera:

Cita:
<?php
session_start();
$_SESSION["captcha"] = 'Prueba';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script type="text/javascript">
<!--
function nuevoAjax(){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}

function validaCaptcha(texto){
if (texto != ''){
ajax = nuevoAjax();
ajax.open("GET","valCaptcha.php?t="+texto,true);
ajax.send();
ajax.onreadystatechange=function() {
if (ajax.readyState==4 && ajax.status==200) {
asignaTexto(ajax.responseText);
}
}
}else{
asignaTexto("f");
}
}

function asignaTexto(str){
document.getElementById('textfield2').value = str;
}

//-->
</script>
</head>
<body>
<p>
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="Enviar" onClick = "validaCaptcha(document.getElementById('textfield' ).value);"/>
<br /><br><input type="text" name="textfield2" id="textfield2" />
</p>
</body>
</html>
Gracias y saludos!