Mam mały problemik otóż skrypt działa tak jak powinien z jedną małą usterka.
Gdy odświeżymy stronę, stoper "zaczyna odliczanie" od cyferki ktora byla w polu input przed odsiwezeniem strony.
Krótko mowiąc chodzi o to, żeby zawsze po odświeżeniu wartość pola stoper było 5.
Oto kod:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> var sekunda=5; function odliczanie(){ document.getElementsByName('stoper')[0].value=sekunda; sekunda--; if(sekunda==0) { sekunda="5"; clearInterval(id); } } function stoper(){ id=setInterval("odliczanie();",1000); } function zmien(){ document.getElementById('pytanie1').style.display="none"; document.getElementById('pytanie2').style.visibility="visible"; document.getElementById('formularz').style.visibility="visible"; } function napisz(){ document.getElementById('pytanie2').style.visibility="hidden"; document.getElementById('formularz').style.visibility="hidden"; stoper(); setInterval("zmien();",6000); } </script> </head> <body onLoad="napisz();"> <div id="pytanie1"> How old are u? <input type="text" name="stoper" value="5"> </div> <br /> <div id="pytanie2"> Napisz zdanie, które widziałeś: </div> <br /> <div id="formularz"> <form action="#" metdod="POST" name="formik"> <input type="text" name="pytanie"> <input type="submit" name="button" value="OK"> </form> </div> </body> </html>