You need to sign in to do that
Don't have an account?
JohnTaylorUK
Pass value of a Javascript Timer into a SFDC field on save ????
Hi All,
I have built a little javascript timer that wii eventually start when a user visits a html page (soon to be a sites page).
I am trying to work out if it would be possible (and how..) to pass the variable from that timer to a field on an object.
I've included the code below if that helps, and im sure im going to need an add an ID= here and there but am a little bit stuck when it comes to writting the controller...
Any help to just work out if this is possible would be great..
Many Thanks to you all...:smileywink:
<HTML> <HEAD> <script language="JavaScript" type="text/javascript"> var sec = 0; var min = 0; var hour = 0; function stopwatch(text) { sec++; if (sec == 60) { sec = 0; min = min + 1; } else { min = min; } if (min == 60) { min = 0; hour += 1; } if (sec<=9) { sec = "0" + sec; } document.clock.stwa.value = ((hour<=9) ? "0"+hour : hour) + " : " + ((min<=9) ? "0" + min : min) + " : " + sec; if (text == "Start") { document.clock.theButton.value = "Stop "; } if (text == "Stop ") { document.clock.theButton.value = "Start"; } if (document.clock.theButton.value == "Start") { window.clearTimeout(SD); return true; } SD=window.setTimeout("stopwatch();", 1000); } function resetIt() { sec = -1; min = 0; hour = 0; if (document.clock.theButton.value == "Stop ") { document.clock.theButton.value = "Start"; } window.clearTimeout(SD); } </script> </HEAD> <BODY> <table bgcolor="#c0c0c0" align="center" border="2" width="140" cellspacing="0"> <tr> <td align="center"> <form name="clock"> <input type="text" size="12" name="stwa" value="00 : 00 : 00" style="text-align:center" /><br /> <input type="button" name="theButton" onClick="stopwatch(this.value);" value="Start" /> <input type="button" value="Reset" onClick="resetIt();reset();" /> </form> </td> </tr> </table> </HTML>
Hi All,
After some work I did manage to sort this out, and without a controller.
Thanks does have to go to Wes Nolte and Jeff Douglas for their support in this.
But below so can see the entire code to build a survey / Logger type tool , with a timer and a button to start it , that will save the time value and all the other fields into the object.
You could easily chnage this to start the timer when a user hits the page by calling the script using OnLoad.
I hope this helps someone out there in the fture.
p.s (Please forgive the really nasty spacing of the form elements to get them to sit nicely on the page ..)