Thanks in advance for any help...
I'm trying to (1) generate a begin time and end time for a form, (2) find the difference between the two, and (3) add the difference to a new input.
Here's what I have so far:
<a href="#" id="starttime">Begin time</a>
<input id="starttimeinput" name="starttimeinput" type="text" value="">
<script>
$("#starttime").click(function () {
var begintime = event.timeStamp;
$("#starttimeinput").val(begintime);
});
</script>
<a href="#" id="endtime">end time</a>
<input id="endtimeinput" name="endtimeinput" type="text" value="">
<script>
$("#endtime").click(function () {
var endtime = event.timeStamp;
$("#endtimeinput").val(endtime);
});
</script>
<input id="totaltime" name="totaltime" type="text">
<script>
$("#totaltime").focus(function () {
var begintime = $("#starttimeinput").val();
var endtime = $("#endtimeinput").val();
var totaltime = endtime - begintime;
$("#totaltime").val(totaltime);
});
</script>
The first part works (entering the timestamps into the beginning time and end time inputs). I've never worked with numbers before and can't figure out the second part. The result that comes up is "NaN".
Also this might be useful to know the the time between when the links are clicked should be around 30 seconds...
Thanks much for any help you guys have answered so many questions of mine without me having to post!
See Question&Answers more detail:os