Witam, potrzebuję skryptu w js, który mierzy czas + są 2 grupy radiobutton, gdy zaznaczę radiobuttony i wcisnę button to zapisuje mi się w tabelce czas i wartości z radiobutton. Uporałem się już ze stoperem lecz nie wiem jak zrobić żeby kolejne czasy zapisywały się do jednej textarea. Również nie wiem jak zrobić żeby się zapisywały wartości z radiobutton do tej samej textarea. Chodzi mi żeby w polu tekstowym wyglądało to następująco np. "0030.94,1,4".
@@edit
Już jest prawie wszystko, lecz brakuje małych poprawek. Czy da się zrobić żeby czas w funkcji showTimes(); był zapisywany nie po kliknięciu radiobutton tylko jak zaznaczę radio buttony i wcisnę button "Mark". Oraz jeżeli się da w ogóle żeby cała baza o zapisanych czasach była zapisywana w .txt do tego samego folderu gdzie znajduje się plik .html ?
<html>
<head>
<title>Javascript Stopwatch</title>
<script language="javascript">
var base = 60;
var clocktimer,dateObj,dh,dm,ds,ms;
var readout='';
var h=1;
var m=1;
var tm=1;
var s=0;
var ts=0;
var ms=0;
var show=true;
var init=0;
function clearALL() {
clearTimeout(clocktimer);
h=1;m=1;tm=1;s=0;ts=0;ms=0;
init=0;show=true;
readout='00:00:00.00';
document.clockform.clock.value=readout;
document.clockform.m0.value = '';
}
function addMEM() {
if (init>0)
{
var mC = document.clockform.m0;
if(mC.value != '')
mC.value = mC.value + "\n" + readout;
else
mC.value = readout;
}
}
function startTIME() {
var cdateObj = new Date();
var t = (cdateObj.getTime() - dateObj.getTime())-(s*1000);
if (t>999) { s++; }
if (s>=(m*base)) {
ts=0;
m++;
} else {
ts=parseInt((ms/100)+s);
if(ts>=base) { ts=ts-((m-1)*base); }
}
if (m>(h*base)) {
tm=1;
h++;
} else {
tm=parseInt((ms/100)+m);
if(tm>=base) { tm=tm-((h-1)*base); }
}
ms = Math.round(t/10);
if (ms>99) {ms=0;}
if (ms==0) {ms='00';}
if (ms>0&&ms<=9) { ms = '0'+ms; }
if (ts>0) { ds = ts; if (ts<10) { ds = '0'+ts; }} else { ds = '00'; }
dm=tm-1;
if (dm>0) { if (dm<10) { dm = '0'+dm; }} else { dm = '00'; }
dh=h-1;
if (dh>0) { if (dh<10) { dh = '0'+dh; }} else { dh = '00'; }
readout = dh + ':' + dm + ':' + ds + '.' + ms;
if (show==true) { document.clockform.clock.value = readout; }
clocktimer = setTimeout("startTIME()",1);
}
function findTIME() {
if (init==0) {
dateObj = new Date();
startTIME();
init=1;
}
}
var times = {};
window.onload=function() {
var inpt = document.getElementsByTagName("input");
for (var i=0,n=inpt.length;i<n;i++) {
if (inpt[i].type=="radio") inpt[i].onclick=function() {
times[this.id]=this.form.m0.value=this.form.clock.value;
}
}
}
function showTimes() {
var text ="";
for (var o in times) text += o+":"+times[o]+"\n"
if (text) alert(text)
}
</script>
</head>
<body bgcolor=tan>
<form name=clockform>
<table bgcolor=cornsilk align=center cellpadding=5 border=1 bordercolor=burlywood><tr><td>
<table cellpadding=3 cellspacing=0 border=0 align=center>
<tr>
<td bgcolor=wheat><input name=clock value="00:00:00.00" style="text-align:center; width:174px; height:35px; font-size:24; font-weight:bold"></td>
<td valign=top bgcolor=wheat><input name=clearer type=button value="Reset" onclick="clearALL()"></td>
</tr>
<tr>
<td colspan=2 bgcolor=wheat>
<input name=starter type=button value="Start" style="width:97px; font-weight:bold" onclick="findTIME()"> <input name=marker type=button value="Mark" style="width:84px" onclick="addMEM()"><br><font style="font-size:9pt"> </font></td>
</tr>
<tr><td>
<input type="radio" name="group1" id="G: 1" value="1"> 1<br>
<input type="radio" name="group1" id="G: 2" value="2"> 2<br>
<input type="radio" name="group1" id="G: 3" value="3"> 3<br>
<input type="radio" name="group1" id="G: 4" value="4"> 4<br>
<input type="radio" name="group1" id="G: 5" value="5"> 5<br>
<input type="radio" name="group1" id="G: 6" value="6"> 6<br>
</td>
<td>
<input type="radio" name="group2" id="A: 1" value="1"> 1<br>
<input type="radio" name="group2" id="A: 2" value="2"> 2<br>
<input type="radio" name="group2" id="A: 3" value="3"> 3<br>
<input type="radio" name="group2" id="A: 4" value="4"> 4<br>
<input type="radio" name="group2" id="A: 5" value="5"> 5<br>
<input type="radio" name="group2" id="A: 6" value="6"> 6<br>
</td>
</tr>
<tr><td colspan="2">
<textarea name="m0" style="text-align:left; width:83px cols="40" rows="5" readonly="readonly">
</textarea>
<input type="button" onclick="showTimes()" value="show times">
</td>
</tr>
</table>
</form>
</body>
</html>