Autosubmitting a form with POST-values

Discussion in 'JavaScript' started by PoPSiCLe, Mar 29, 2009.

  1. #1
    Hi. I have a page where I generate content based on checkbox-values. It's working fine.

    Some of the values on the generated page is editable - if a user edits the value, a second page (.php) is called, submitting the changes to the database.

    Now, what I would like this page to do, is redirect back to the generated page using the same values as first used when generating it.

    Ie:

    If a user selects to show "name", "address" and "pay date" - and then decides to change one of these values, the second page should redirect to the first, setting "name", "address" and "pay date" to true. The form part is working fine, I get the values posted through hidden fields in the first page, and they show up correctly on the second page.

    What I would like to do, however, is to have the form/values on the second page autosubmit back to the first page.

    So... how do I get the form to autosubmit back to the first page?

    Right now I have the whole logic part working, but I have to click the button on the second page form to go back, as it does not auto-submit.
     
    PoPSiCLe, Mar 29, 2009 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Nevermind - I figured it out:
    
    <script type="text/javascript">
    function submitForm(){
    var form = document.postvalues;
    form.submit();
    }
    </script> 
    REST OF CODE HERE
    <script type="text/javascript">
    submitForm();
    </script>
    
    Code (markup):
     
    PoPSiCLe, Mar 29, 2009 IP