Website Babble Webmaster Forums  


Go Back   Website Babble Webmaster Forums > Creating a Website > HTML, PHP, CSS, Javascript & Coding/Programming Topics

Your WB Notifications

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-03-2009, 01:01 PM
vlad11's Avatar
Master Babbler
 
Join Date: Aug 2009
Posts: 147
vlad11 has no reputation at Website Babble yet.
Send a message via Skype™ to vlad11
Default New window

Can anyone tell me how to dispaly the results of a form(a .php file) in a "pop up" type window (just a window, not buttons or anything).
It's like <form method="post" action="script.php">....</form>
Thx.
__________________
Websites:
http://www.learnweb4u.com
Reply With Quote
  #2 (permalink)  
Old 11-03-2009, 05:03 PM
sequencehosting's Avatar
Ultimate Babbler
 
Join Date: Jun 2009
Location: Kent, England
Posts: 1,467
sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)
Default

Quote:
Originally Posted by vlad11 View Post
Can anyone tell me how to dispaly the results of a form(a .php file) in a "pop up" type window (just a window, not buttons or anything).
It's like <form method="post" action="script.php">....</form>
Thx.
That's a good question, im not too sure about this. I know how to do it with a normal text link but not a web form. Maybe someone on here will know.
__________________
Sequence Hosting - $1/mo cPanel hosting! - Why pay more for less?
Web Hosting Affiliate Program - 20% Lifetime Commissions!
Our long awaited 30 Day Free Hosting Trial is here! ORDER NOW!
Skateboarding Videos < Almost finished!
Reply With Quote
  #3 (permalink)  
Old 11-04-2009, 12:42 PM
meloncholy's Avatar
Master Babbler
 
Join Date: May 2009
Posts: 158
meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)
Default

This is quite an interesting question - hadn't thought about it before. So thanks.

We can use the form's onsubmit event to trap the submit action and launch a popup through window.open, but unfortunately the form's contents aren't set in $_POST (or whatever) for the popup even if we let the form submit. (The original window gets values from $_POST, the popup doesn't.)

We can use the JavaScript form.submit function to get round this, but first we need to make sure the form's results appear in the popup by setting the form's target.

This approach also ensures that, without JavaScript, the form will submit normally to the same window.

So the steps are:

- Create a blank popup window.
- Set the form target to the popup.
- Submit the form.
- Return false to stop the original page submitting too.

HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
		function popupSubmit()
		{
			var popupForm;

			popupForm = document.getElementById("popupForm");
			window.open("", "popupSubmit", "width=500, height=500");
			popupForm.target = "popupSubmit";
			popupForm.submit();
			return false;
		}
    </script>
</head>
<body>
<form id="popupForm" method="post" action="tstsubmit.php" onsubmit="popupSubmit();">
	<input type="text" name="name" />
	<input type="submit" value="Submit" />
</form>
</body>
</html>
__________________
Pole Exercise - Pole dancing evolved
Reply With Quote
  #4 (permalink)  
Old 11-04-2009, 12:56 PM
vlad11's Avatar
Master Babbler
 
Join Date: Aug 2009
Posts: 147
vlad11 has no reputation at Website Babble yet.
Send a message via Skype™ to vlad11
Default

Thanks man!
__________________
Websites:
http://www.learnweb4u.com
Reply With Quote
  #5 (permalink)  
Old 11-13-2009, 04:33 PM
Regular Babbler
 
Join Date: Nov 2009
Posts: 36
designerpk.com has no reputation at Website Babble yet.
Send a message via Yahoo to designerpk.com
Default

thanks this is helpful
Reply With Quote
  #6 (permalink)  
Old 11-14-2009, 08:36 AM
meloncholy's Avatar
Master Babbler
 
Join Date: May 2009
Posts: 158
meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)meloncholy has an outstanding reputation at WB (over 500 points)
Default

Thanks for the comments, guys.

It occurred to me afterwards that I could have simplified the code a little. It's not necessary to submit the form with JS and then cancel the original submit; just changing the target is sufficient. (This isn't a major change, but it makes me happy. )

HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
		function popupSubmit()
		{
			var popupForm;

			popupForm = document.getElementById("popupForm");
			window.open("", "popupSubmit", "width=500, height=500");
			popupForm.target = "popupSubmit";
		}
    </script>
</head>
<body>
<form id="popupForm" method="post" action="tstsubmit.php" onsubmit="popupSubmit();">
	<input type="text" name="name" />
	<input type="submit" value="Submit" />
</form>
</body>
</html>
__________________
Pole Exercise - Pole dancing evolved
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -6. The time now is 05:32 PM.


 Subscribe to RSS

WB Sponsors

Search Engine Optimization

flash chat

Home Jobs Online

Search Engine Marketing

Paid Surveys

Web Design Company

custom website design

Best Links Management Software

Online Advertising Solution FREE trial!



 Subscribe to the Website Babble Feeds

2 Create a Website Homepage | 2 Create a Website Blog


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0