Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    CPD
    CPD is offline
    New Coder
    Join Date
    Jul 2012
    Location
    Ontario Canada
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    IF statement auto submit

    Hello All
    I need to frequently do an auto submit after an sql query to advance to the next stage of the form

    Here is a simplified piece of code as an example of what I am trying to do
    This is the Javascript which works fine for the sections where I use onclick="autoSubmit();"
    Code:
    <script language="JavaScript">
    
    function autoSubmit()
    {
        var formObject = document.forms['theForm'];
        formObject.submit();
    }
    </script>
    And this is the PHP which after a $var is set I need an auto submit

    PHP Code:
    <?php
     
    if($var != null )
        {    
    autoSubmit();    }
        
        
    ?>
    But it wont work for me
    any Ideas ??
    Last edited by CPD; 08-03-2012 at 09:38 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Have you defined autoSubmit in the PHP code anywhere? PHP and Javascript are not capable of communicating directly as PHP is processed prior to sending data to the client.

  • #3
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Code:
    <script type="text/javascript">
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

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