Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-17-2005, 02:31 PM   #1
andrewf
Registered User
 
andrewf's Avatar
 
Join Date: Jul 2004
Posts: 31
Exclamation Html/php Form - Single Button Performs 2 Actions? How?

Hello,

I have an HTML form where visitors fill out their
Name: ________
Phone:________
Email: _________

And they have the option of browsing their computer for a file, and then uploading the file to my server.


The problem is I have 2 different actions and I want just 1 Button to perform both...

The first action sends the info they provided including their "name, phone, email and the name of the file they uploaded (not the actual file, just the name of it) to me via email.

That action looks like this: action="<?= $PHP_SELF ?>"



The second action is used to upload the file to my server.

It looks like this: action="uploadresults.php"


I can get the submit button to perform either one of the actions... but I can't get it to do both... And I really need just 1 button to do both.

What I would really like is for the first action (the one that sends off the email to me) to happen in the current browser window. And the second action (the one that uploads the file) to happen in a new pop up window...

So the result when you click the button would be that the page basically refreshes and shows my message saying "Thank you your message has been sent" And a second window opens that says "Your file has been uploaded."


I have been searching all over Google and it seems as though you can't really have two actions with just one submit button... But there has to be a way using JavaScript or something to perform both actions.


Any help or direction would be great!

Thanks, Andrew
andrewf is offline   Reply With Quote
Old 06-18-2005, 06:00 AM   #2
ZBC
Registered User
 
ZBC's Avatar
 
Join Date: Aug 2004
Location: USA
Posts: 94
Send a message via MSN to ZBC
Default

Well I think I have what you need. Fisrt you would submit the first part with the email and so on. Then when you display the thank message this code will pop up the the window that will do the rest.
HTML Code:
<SCRIPT LANGUAGE="JavaScript">

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=200');");
}
</script>


<BODY onLoad="javascript:popUp('http://www..com')">
Just the width and height of the the pop up in the javascript and
put the url to the php file that submits the file with the information in the url like:
HTML Code:
<BODY onLoad="javascript:popUp('http://www.test.com/submit.php?file=c:\file.zip')">
So you can grab the infromation from the url to send to the server. Hope that helps

Last edited by ZBC; 06-18-2005 at 06:03 AM.
ZBC is offline   Reply With Quote
Old 06-20-2005, 02:51 PM   #3
andrewf
Registered User
 
andrewf's Avatar
 
Join Date: Jul 2004
Posts: 31
Question A few more questions...

Thanks for the reply ZBC,

However I submit the first part (the email into) using "<?= $PHP_SELF ?>"
So it doesn't really load a new page... So how would I include the javascript popup function?

I currently am just using:

echo "Thanks for sending us an email"

to display the thank you message...

So at this point I am a little stuck...

Any advice?

Thanks, Andrew
andrewf is offline   Reply With Quote
Old 06-21-2005, 10:27 PM   #4
ZBC
Registered User
 
ZBC's Avatar
 
Join Date: Aug 2004
Location: USA
Posts: 94
Send a message via MSN to ZBC
Default

When you echo the thank you message you need to put the html code around it. Like so.
HTML Code:
<html>
<head>
<title>Some title</title>
<SCRIPT LANGUAGE="JavaScript">

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=200');");
}
</script>
</head>

<BODY onLoad="javascript:popUp('http://www.test.com/submit.php?file=<? echo "$file_name"; ?>')">
<?
echo "Thanks for sending us an email";
?>
</body>
</html>
The variable called $file_name is the name of the file that your php code in the pop up that will load to the server, and any other php code can go above the html code.
ZBC is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:42 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.