one form and one button with multiple action

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • c h e r r y
    New Member
    • Feb 2009
    • 4

    one form and one button with multiple action

    Hi!
    I have this code that only submit to checklogin.php
    I've tried interchanging the destinations for the submit and i always end up having the data only at the last argument.
    Please help me.

    Code:
    <script language="javascript">
    function submitme()
    {
    document.Form1.action = "init_profile.php"; //first destination
    document.Form1.submit(); 
     
    document.Form1.action = "getmempicture.php" //second destination
    document.Form1.submit();    
    	
    document.Form1.action = "init_profile.php" //third destination
    document.Form1.submit();        
    
    document.Form1.action =  "checklogin.php"; //forth destination
    document.Form1.submit();    
    
    return true;
    
    }
    </script>
    
    <form name="Form1" method="post" action="checklogin.php" onSubmit="return submitme()">
    <b>Log In Account</b><br /><br />
    Username: <input  type="text" id="myusername" /><br />
    Password: <input type="password"  id="mypassword" /><br /><br />
    <input type=reset value="Clear" />
    <input type="submit" name="Button1" value="Login" />
    </form>
    Last edited by Dormilich; Feb 6 '09, 08:03 AM. Reason: added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You can't reuse the same form for multiple submits like this. Either use Ajax or multiple forms.

    Comment

    • c h e r r y
      New Member
      • Feb 2009
      • 4

      #3
      i've tried placing a target for each of the destination and it worked. now my problem is that it opens 4 different browser windows. i only need one window having the all the contents from the 4 url's

      Code:
      document.Form1.action = "init_profile.php"; //first destination 
      document.Form1.target = "init_profile.php";
      document.Form1.submit();  
        
      document.Form1.action = "getmempicture.php" //second destination 
      document.Form1.target = "getmempicture.php";
      document.Form1.submit();     
        
      document.Form1.action = "showimage.php" //third destination
      document.Form1.target = "showimage.php";
      document.Form1.submit();         
        
      document.Form1.action =  "checklogin.php"; //forth destination
      document.Form1.target = "checklogin.php";
      document.Form1.submit();
      Last edited by acoder; Feb 9 '09, 09:25 AM. Reason: Added [code] tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Setting the target sets the target to the name of the window. Since the window doesn't exist, it opens a new one.

        You can solve this by using a combination of JavaScript and server-side code or using iframes/frames. The easiest way to solve this would be to submit to one page which takes the form data and runs it through the 4 pages and returns the collated result.

        Comment

        • c h e r r y
          New Member
          • Feb 2009
          • 4

          #5
          ok! thanx for that. i'll try it.

          Comment

          • dkhanna01
            New Member
            • Oct 2009
            • 2

            #6
            Im not sure if I understood correctly. what I am doing right now is:

            <form enctype='multip art/form-data' method='post' action=''proces s.php" target="_blank" >
            Now by doing this it execute process.php in new window which exactly what I wanted but now in addition to this I just want to reload this same page.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              You could reload from the opened page, via window.opener.l ocation.reload( )

              Comment

              Working...