This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Automatically submit a form using a timer


  1. Alasdair
    Member

    Hi everyone,

    I was wondering, is it possible to automatically submit a form using javascript?

    I have multiple forms that after submission populate a Machform form/fields automatically. My plan is to change the standard machform input fields to "hidden" and "display:none" and automatically submit the form after 5 seconds so I can save the data in Machform (because it's great!)

    On other forms i use code similar to:

    <script type='text/javascript'>

    setInterval ( "autosubmit()", 5000 );

    function autosubmit()
    {
    document.theFormName.submit;
    }

    </script>

    Would this work?

    Posted 15 years ago #
  2. yuniar

    I think that should work.
    The easiest way to add the javascript code is by copying the code into your "form description" field.

    However, you need to adjust the code into a single line, like this:

    <script type='text/javascript'>setInterval( "autosubmit()", 5000 );function autosubmit(){ document.theFormName.submit;}</script>

    Make sure it's only a single line of code


    MachForm Founder

    Posted 15 years ago #
  3. Alasdair
    Member

    Hi Yuniar,

    Many thanks for the speedy reply.

    I'll give that a try. Should I specify a generic name for the form? I'm thinking that would let any form_id post. i.e if the form is named "postmyform" then any form and ID should automatically post....

    Cheers

    Alasdair

    Posted 15 years ago #
  4. Alasdair
    Member

    Hiya,

    I've tried inserting the code into the form description field but unfortunately can't get it to work. Have also tried without a timer.

    My changes were to add <form name = "autosubmit" and adding the code:

    <script type='text/javascript'>setInterval( "autosubmit()", 5000 );function autosubmit(){ document.autosubmit.submit;}</script>

    I noticed that it was creating an error on the actual form editing page in the Machform backend, but sometimes it would add and save.

    Could you test this and see if it works for you?

    Kind regards,

    Alasdair

    Posted 15 years ago #
  5. yuniar

    Sorry for delayed response on this! I've just tested and it doesn't seem to work indeed.
    We might need to do some direct modification to one of MachForm file for this.

    Can you send me your "includes/view-functions.php" file and let me know the URL to one of your form?

    I'll try to do the modification and send it back to you.

    Please mail to: customer.service [at] appnitro.com


    MachForm Founder

    Posted 15 years ago #

RSS feed for this topic

Reply