SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Automatically submitting a form

    This maybe a simple question, but I've never had to do it before.

    How do I automatically submit a form, preferably with JavaScript?

    I have a form with an action attribute to where to send data, some hidden fields and some radio buttons with default values, a submit button at the bottom, and a javascript timer that starts on the body onLoad event. The trick is that when the timer runs out, I want the form automatically submitted.

    Thanks
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  2. #2
    SitePoint Guru
    Join Date
    Sep 1999
    Location
    Singapore
    Posts
    854
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm assuming the time limit is 30 seconds, and the form name is "theform".

    It'll be something like this:

    Code:
    <SCRIPT LANGUAGE="Javascript">
    <!--
            var x = 30
            var y = 1
            function countDown(){
            x = x-y
            setTimeout("countDown()", 1000)
            if(x==0){
            document.theform.submit();
               }
            }
    //-->
    </SCRIPT>
    Something like that anyway...I'm not too sure if the syntax is 100% correct.

  3. #3
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    document.form.submit()
    That was just what I was looking for. And guess what, it was right in the DOM tree within my HTML editor.

    D'oh!
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •