Question:

Help with HTML and timers on websites...?

by Guest66218  |  earlier

0 LIKES UnLike

It's been a while since I have dabbled in website design and so am am hoping someone can help with the following:

I am trying to design a website where a user is directed to a page where there is a simple text box and "Submit" button but they have only a limited amount of time to type in the box and at the end of that time whatever they have typed is submitted (or of course they can cick submit before the time is up). Think of it as like an online timed exam question. How easy/possible is this for an amateur? Any assistance appreciated.

 Tags:

   Report

6 ANSWERS


  1. To submit using a time frame, you'll need JavaScript.

    Assuming PHP for the heck of it (to parse the submitted answer):

    <script type="text/javascript" >

    function submitform(){

    document.quiz.submit();

    }

    window.onload = function() {

    setTimeOut ( submitform(), 30000 );

    }

    </script>

    <form name="quiz" action="quiz2.php" method="post">

    Question here... : <input type="text" name="answer" />

    <input type="button" name="submit" value="Next" onclick=" submitform();" />

    </form>

    Using a "button" instead of a "submit" will allow you to do a scripted form submit (because Internet Explorer refuses to autosubmit a form if an actual "submit" button is available)

    The setTimeOut function automatically calls a function after x amount of milliseconds.


  2. about timer

    user will be forwarded to a next page withing a 30 seconds

    insert this line into <head> section of your html page with a question

    <META HTTP-EQUIV=REFRESH CONTENT="30; URL=http://www.example.org/nextpage.html...

  3. I've been designing websites for over a year now and I have no idea how to do this.  You could most likely to do with Javascript or another browser side code.

    :D

  4. Unfortunately although Randy's solution will take you to a new page, because it's not part of the Form mechanism no data will be submitted, simply a new Get request for the new page.

  5. Hi try this site

    http://www.html.co.uk/

    or

    http://vzone.virgin.net/sizzling.jalfrez...

  6. Bon...

    The question page:

    The form you want to send:

    <form id = ' myform ' action = ' nextpage.php '

    // action is the script the form is sent to.

    onsubmit = ' js_stoptimer() ;return false; '

    // this will stop the timer

    method = post>

    // insure you use the POST method.

    <textarea cols = 20 rows = 20></textarea>

    // where the user enters his text

    <input type = 'submit' name=submit value=submit />

    // this one above will send the form on click.

    </form>

    Now the script to send it automatically.

    <script>

    var TO = setTimeout ( "sendit(), 10000 );

    // var TO is a global that identifies the timer.

    // 10,000 is 10 seconds: value in milliseconds

    // the function to send the form after timeout:

    function sendit ( )

    {

    var x = document.forms [ ' myform ' ] ;

    x.submit ( );

    }

    // the function to stop the timer:

    function js_stoptimer()

    {

    cleartimeout ( TO);

    }

    I think this will do the job nicely!

    (remove added spaces and comments)

Question Stats

Latest activity: earlier.
This question has 6 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.