SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript form submission in a new window

    Hi all.

    I am usinging this function to open my form processing script.

    Code:
    //new Window
    myPopup = '';
    
    function openPopup(url) {
        myPopup = window.open(url,'popupWindow','width=640,height=480');
        if (!myPopup.opener)
             myPopup.opener = self; 
    }
    
                <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>" class="subscribe" onsubmit="openPopup('../../mailSubscription.php')" >
    I am suspecting that the new window is opened and the form processing script (a regular enough php class) are being executed prior to the action="..." part being run / completed. Therefore the form data hasnt been sumbitted yet.

    Is there a way to meld the two? So that I can use the details entered into the form for use by my the form processing class in the new javascript window?

    thanks, in advance,
    porle.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about this:

    Code:
    <body <? if (isset($_POST['submitfieldname'])) echo 'onload="openPopup(\'../../mailSubscription.php\')"'; ?> >
    
                <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>" class="subscribe">
    well... it turns to php thing

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Explorer, thanks for the reply, that makes perfect sense. I will let you know how it goes. I appreciate you taking the time to reply.

    Cheers,
    Porle.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Explorer, hmm no i still seem to having problems with getting the form data to the popup window. No matter, I have done something simpler as time is against me. Thanks for your input

    p.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh I was only focusing into the problem that onsubmit is executed before the form submitted, so I thought that your main php page (the one that is called in the form action) will contain its own php codes that processing the form data (such as save them into the database) and then mailSubscription.php will get the data from db. If you meant that you need to evaluate for example $_POST variable in mailSubscription.php, the $_POST variable will not be set. Sorry for not explaining this to you earlier...

    Anyway, glad to hear you already had simpler way..


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
  •