Ver Mensaje Individual
  #7 (permalink)  
Antiguo 17/10/2012, 12:52
KAKOROSAS
 
Fecha de Ingreso: enero-2004
Mensajes: 72
Antigüedad: 20 años, 4 meses
Puntos: 1
Respuesta: cuenta regresiva con submit automatico

aki esta el codigo de muestra

si se dan cuenta al terminar el tiempo simulo el click del boton enviar .... pero me aparese el otro js donde me avisa de las preguntas sin responder y con la opcion cancelar ..

la idea es que no tenga opción cancelar al terminar el tiempo .. o que envie si o si al terminar el tiempo sin preguntar nada ..

muchas gracias por su tiempo

Código PHP:
<!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>
* * * *function 
comprobarPregunta(ele){
* * var 
radios document.getElementsByName(ele);
* * var 
noContesto true;
* * for(var 
x=0;radios[x];x++){
* * * * if(
radios[x].checked){
* * * * * * 
noContesto false;
* * * * * * break;
* * * * }
* * }
* * return 
noContesto;
}
function 
validar(){
* * var 
ele document.forms['form2'].elements;
* * var 
name '';
* * var 
noContestados '';
* * for(var 
x=0;ele[x];x++){
* * * * if(
ele[x].type == "radio" && ele[x].name!=name){
* * * * * * 
name ele[x].name;
* * * * * * 
noContestados += comprobarPregunta(ele[x].name) ? (name.replace(/D/gi,"") + ', ') : '';
* * * * }else{
* * * * * * continue;
* * * * }
* * }
*
* * if(
noContestados!=''){
* * * * 
// CON ESTO ESTOY VERIFICANDO QUE SI PONE EN ACEPTAR ENTONCES REALIZAR EL SUBMIT DE LO CONTRARIO QUE NO HAGA EL SUBMIT
* * * * if(confirm("Falta responer las siguientes preguntas " noContestados.substr(0,noContestados.length-2))){
* * * * * * return 
true;
* * * * }else{
* * * * * * return 
false;
* * * * }
* * }
* * return 
true;
}

* * 
</script>

<script type="text/javascript">
var comprobar = comprobar || {};
*
comprobar.tiempo =10;
comprobar.contador = setInterval(function() {
* *comprobar.tiempo -= 1;
* if (comprobar.tiempo === 9) {
* * return alert('Te quedan 9 segundos');
return false;
}
if (comprobar.tiempo === 7) {
* * return alert('Te quedan 7 segundos');
* }
if (comprobar.tiempo === 1) {
    document.getElementById('enviar').click()
    return true;
}
}, 1000);
</script>
</head> 
*
<body> 
<form id="form2" name="form2" method="post" action="" onsubmit="return validar();"> 
* * pregunta 1
* <p> 
* * <label> 
* * * <input type="radio" name="a1" value="a" id="a1_0" /> 
* * * a</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a1" value="b" id="a1_1" /> 
* * * b</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a1" value="c" id="a1_2" /> 
* * * c</label> 
* * <br /> 
* </p>
* * <br/>
* * pregunta 2
* <p> 
* * <label> 
* * * <input type="radio" name="a2" value="a" id="a2_0" /> 
* * * a</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a2" value="b" id="a2_1" /> 
* * * b</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a2" value="c" id="a2_2" /> 
* * * c</label> 
* </p> 
* * <br/>
* * pregunta 3
* <p> 
* * <label> 
* * * <input type="radio" name="a3" value="a" id="a2_3" /> 
* * * a</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a3" value="b" id="a2_4" /> 
* * * b</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a3" value="c" id="a2_5" /> 
* * * c</label> 
</p> 
* * <br/>
* * pregunta 4
* <p> 
* * <label> 
* * * <input type="radio" name="a4" value="a" id="a2_6" /> 
* * * a</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a4" value="b" id="a2_7" /> 
* * * b</label> 
* * <br /> 
* * <label> 
* * * <input type="radio" name="a4" value="c" id="a2_8" /> 
* * * c</label> 
* </p> 
* <p><br /> 
* </p> 
* <p> * *<input type="submit" name="enviar" id="enviar" value="Enviar" /><br /> 
</p> 
</form> 
</body> 
</html> *​