My question is a combination of PHP, Javascript and HTML.

Overview, I have a form the user fills out... they go through all the pages to the end. I'm passing my php variables (the main chunk is built in php) throughout so at the end they click the submit button and the information is loaded into a database.

What I'd like to have happen when the user presses the submit button is the following:

Little window popups... gif flashes saying the page is working... after a set time the popup closes and the parent window redirects to a thank you page.

The button is defined thusly:
<input TYPE='submit' name='buttonname' value='Submit Registration' onclick="Completewin()" >

(The CompleteWin function is this:
function Completewin()
{
window.open('submitregistration.php','jav','scrollbars=yes,status=no,toolbar=no,resizable=no,width=800,height=800,top=150,left=185');
setTimeout('document.location = "thankyou.php"',5000)
})

This works in a way. The popup window appears (it's big here so I can view it). However, the parent window also redirects to the submitregistration.php page... which I do not want to happen. I want it to remain on the calling page before it's redirected to thankyou.php.

IF I change the HTML tag to:
<Input Type="button" .... >

Then the parent page stays as it is, and after the set time redirects to thankyou.php. HOWEVER, using button, my php variables do not pass to the submitregistration.php page, so they cannot be loaded into the database.

Ugh.

I would love some help. I've been googling all day and haven't found the answers I need. Thanks!

    In your Javascript, try adding:

    this.form.form_name.submit();

    after the pop-up, but before the timeout.

    Not sure it will work, but it's something...

    ~Brett

      Thanks for the reply. I redid the logic... using more php and less javascript. And read up on input type=button vs input type=submit. Seems buttons don't do anything except whatever onclick event is defined. While submits will submit the form. Thus no variables pass with a button. Probably to get them to pass I'd have to code it all in javascript which would be a pain since the submit passes my php variables for me. So nevermind that. 🙂

      I have a little popup window now that has the user wait.. unfortunately it doesn't do anything but look pretty. 🙂 It auto-closes after 5 seconds, then my main page has a sleep(5) in there to wait the same amount of time in php, then reloads with the sql page to add the info to the db. Works.

        Write a Reply...