Ecco quà....dopo tanto provare non ci riesco proprio!!!!
Vorrei tramite i checkbox abilitare o meno la partenza dei timer.
Una sequenza possibile sarebbe:
1) checkbox fleggati - schiaccio start/stop e i timer partono.
2) schiaccio start/stop e i timer si fermano.
3) tolgo il flag ad uno dei due e schiaccio start/stop, parte solo quello fleggato e l'altro rimane fermo visualizzando il tempo che aveva incrementato.
4) schiaccio start/stop e i timer si fermano.
5) inverto i flag e i timer si comportano al contrario del punto 3.
6) tolgo i flag da ambedue e i timer non partono....
7) metto i flag ad ambedue e i timer partono....
Questo il codice:
Vi prego datemi una mano.....il progetto consisterebbe nel registrare i tempi di gioco di giocatori di pallacanestro e i flag sono i giocatori in campo.....codice:<head> <FORM NAME="stpw"> <SCRIPT LANGUAGE="JavaScript"> <!-- INIZIO var ms = 0; var state = 0; function startstop() { if (state == 0) { state = 1; then = new Date(); then.setTime(then.getTime() - ms); } else { state = 0; now = new Date(); ms = now.getTime() - then.getTime(); document.stpw.time.value = ms; document.stpw.time1.value = ms; } } function swreset() { state = 0; ms = 0; document.stpw.time.value = ms; document.stpw.time1.value = ms; } function display() { setTimeout("display();", 50); if (state == 1) {now = new Date(); ms = now.getTime() - then.getTime(); document.stpw.time.value = ms; document.stpw.time1.value = ms; } } // FINE --> </SCRIPT> </head> <BODY onLoad="display()"> <CENTER> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="26%" id="AutoNumber1"> <tr> <td width="36%"><input type="checkbox" name="pippo" value="1" ></td> <td width="64%"><INPUT TYPE="text" Name="time" size="20"></td> </tr> <tr> <td width="36%"><input type="checkbox" name="pluto" value="1" ></td> <td width="64%"><INPUT TYPE="text" Name="time1" size="20"></td> </tr> <tr> <td width="36%"> <INPUT TYPE="BUTTON" Name="ssbutton" VALUE="Start/Stop" onClick="startstop()"></td> <td width="64%"> <INPUT TYPE="BUTTON" NAME="reset" VALUE="Reset" onClick="swreset()"></td> </tr> </table> </FORM> </CENTER> </body>
Grazie!!!

Rispondi quotando