H there this is my first post! I wanted to ask if anyone could come up with something to solve my quite simple program. With the following code you can program a simple stopwatch, what I want to add is a button than when the stopwatch is stopped, and you click, that the recorded time is recorded and displayed elsewhere (without reloding)
the code is the following...
Code:
<html>
<head>
<script type="text/javascript">
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout("timedCount()",1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
</script>
</head>
<body>
<form>
<input type="button" value="Start count!" onClick="doTimer()">
<input type="text" id="txt">
<input type="button" value="Stop count!" onClick="stopCount()">
</form>
</body>
</html>
I´m aware im quite a newbie to all this and that my question is quite simple and maybe to vague but I hope you can help me anyways
Cheers to you all and thanks in advance
Trufa
Last edited by Kor; 12-22-2009 at 04:30 AM.
Reason: wrap the code [code][/code]
H there this is my first post! I wanted to ask if anyone could come up with something to solve my quite simple program. With the following code you can program a simple stopwatch, what I want to add is a button than when the stopwatch is stopped, and you click, that the recorded time is recorded and displayed elsewhere (without reloding)
the code is the following...
Code:
// Put your code between the [ code] and [ /code] tags (without spaces)
// to make it stand out and be easier to read by the forum members.
I´m aware im quite a newbie to all this and that my question is quite simple and maybe to vague but I hope you can help me anyways
Cheers to you all and thanks in advance
Trufa
Unclear of the request ...
Where is the 'elsewhere'?
Same page?
Pop-up <div> section?
Opened in a new window?
Passed to an existing page?
What do you mean by 'recorded'?
Saved to a file?
Saved to a cookie?
Passed to the server?
hey sorry about JMARKER and thanks for the advice, the thing is I have two big problems:
1) English is not my language
2) I´m a COMPLETE newbie!!!!!!
I could solve my problem in another forum anyway:
I leave it in case anybody has the same doubt!
Code:
<html>
<head>
<script type="text/javascript">
var c=0;
var t;
var timer_is_on=0;
var x=1;
function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout("timedCount()",1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
function saveSeconds()
{
var seconds = document.getElementById('txt').value;
if (!timer_is_on && seconds != '')
{
document.getElementById('save').value = document.getElementById('save').value + x++ + ":" + seconds + '\n';
c=0;
document.getElementById('txt').value = '';
}
}
</script>
</head>
<body>
<form>
<input type="button" value="Start count!" onClick="doTimer()">
<input type="text" id="txt">
<input type="button" value="Stop count!" onClick="stopCount()">
<input type="button" value="Save" onClick="saveSeconds()">
<br>
<textarea id="save" name="save" cols="10" rows="10"></textarea>
</form>
</body>
</html>
I have another question but will go in a new thread!
Bookmarks