vigiw Posted August 9, 2006 Share Posted August 9, 2006 Hi there, How do I make it so my HTML form can have a hidden field or something that is keeping track of the time it takes to complete the entire form? I am working on an application that requires experience, so it will be an online test/exam. If anyone could help me out, that would be great, thanks!!! All help is appreciated! :) Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 You could set a session variable (make it an array) and record the time the request was recieved to display the next page in the exam.ORyou could use javascript to do the same thing - record start/stop time for each pageeither way you don't need a hidden field to achieve it. Quote Link to comment Share on other sites More sharing options...
vigiw Posted August 9, 2006 Author Share Posted August 9, 2006 Hello, Thanks for your input! Javascript sounds easier, so I will try that out. Do you have a code to do so, or know where I could find one? I am not a good code-maker, a better form maker and paster. ;) Please let me know, or anyone else out there!Thanks again! Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 have a look look at the Timing event in an infinite loop - with a Stop button example on this page. [url=http://www.w3schools.com/js/js_timing.asp]http://www.w3schools.com/js/js_timing.asp[/url] everything you need is in there. Just change the script so that tht timer starts on page load (onLoad in the body tag) and add the onClick event to your submit button. Quote Link to comment Share on other sites More sharing options...
vigiw Posted August 9, 2006 Author Share Posted August 9, 2006 Sorry for the late reply, I was making a sample form. I am testing it out but thought of something:How do I get the time start and end to be saved in the form results?I sent the form to my e-mail address and I only got the multiple choice questions, not the times.Thanks. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 I think it would be better tohave the form on your server and just send a link to it in the e-mail. depending on where the users accesses the form js may be disabled.You will also have to check that js in enabled on the page the script is running on - which is why I think you should use the server to monitor the times via the sesion variable that way you don't have to worry about js being on or off. Quote Link to comment Share on other sites More sharing options...
vigiw Posted August 9, 2006 Author Share Posted August 9, 2006 The file is on my server, it is on the web right now at my site (see http://www.vigilantweather.com/forecast/tester.html) -- the results are sent to my e-mail address is what I meant.I am pretty sure JS is on, because I use scripts quite a bit. I am writing this with MS Frontpage 2003. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 its not whether js is on on your machine - its whether the person filling in the form has js on.One way of ensuring they have js on when answering is to use js to produce the submit button using document.write('<input type="sumit" ....Having looked at your html....change <body><onload="timedcount">to <body onLoad="timedCount();">remove the document.getelementbyid line in the timed count function.and add a semicolon after the stopCount() in the onClick event of the submit button.The action of your form MUST point to something cabale of processing the data in the manner you want.../_vti_bin/shtml.exe/forecast/tester.html can that send an email? (i know is an exe but I have never used a method liek that - suppose thats why I use php ;) ) Quote Link to comment Share on other sites More sharing options...
vigiw Posted August 9, 2006 Author Share Posted August 9, 2006 It can send e-mail, but each time you have entered data in the form, and I, still nothing, even after the edits!By the way, when I add document.write it shows up as text, so here is my current line for the submit button, think you could improvise? <input type="submit" value="Submit!" name="Submit" onClick="stopCount()";>I am getting the e-mail, but it is not working (what I want to work-->the timer).Will PHP work, like you said, you prefer it. I don't know how to code for the PHP form though, I am more so a simple HTML form person.Thanks. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 Kinda my bad here.you need to set a variable equal to the time AND (embarrassed) have a hidden field of that variable name.so put in anywhere in your form <input type="hidden" name="timetaken" id="timetaken" value="">then the onSubmit attribute of the form put onSubmit="setTimetaken()"and add thsi function in the js in the head of the page (under your timedCount function)function setTimetaken () { document.getElementById('timetaken').value = c;} Quote Link to comment Share on other sites More sharing options...
vigiw Posted August 9, 2006 Author Share Posted August 9, 2006 That's ok..Hmm... getting there...This was in the form results e-mailed to me:timetaken: No number, but there are many spaces after the "timetaken:" in the e-mail (highlight this post, above, I included the spaces)Any thoughts?Thanks. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 Shouldn't make any difference BUT just thought you don't need the new setTime taken function.Cut and paste the document.getElementById line into the stopCount function and delete the setTimetaken function and all references to it.As for the email - check that the variable names match in the script that processes the data. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.