The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
HTML form and onlclick window.open
Discuss HTML form and onlclick window.open in the JavaScript Development forum on Dev Shed. HTML form and onlclick window.open JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 14th, 2006, 02:18 PM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 14
Time spent in forums: 2 h 20 m 59 sec
Reputation Power: 0
|
|
|
HTML form and onlclick window.open
Hi,
I have a simple html form which when submitted I want to popup a new window which I can control the size of. Further, in the popup window I want to be able to access the form data.
This is what I have done so far......
Code:
Original
- Code |
|
|
|
<form>
<input type=text name=email size=27>
<input class=button type="image" src="images/submit.jpg" onClick="window.open('send.php?subscribe=1', 'newWindow','width=300,height=150,'+'status=no,toolbar=no,menubar=no')">
</form>
When I submit the popup windows opens correctly and I am trying to access and output the two variables with php as follows:
Code:
Original
- Code |
|
|
|
$email = $_POST["email"];
$subscribe = $_GET["subscribe"];
echo $email $subscribe;
Only the 'subscribe' variable which is passed in the url outputs correctly. [I] So my question is how do I accesss the variable input by the user into the form from the original page.[/I]
Many thanks in advance.
Rob.
|

March 14th, 2006, 02:53 PM
|
|
|
|
1. Use the onsubmit event on the <form> instead of onclick on the <input>
2. Set the target of the form to newWindow.
3. Specify the method of the form to either GET or POST.
|

March 14th, 2006, 05:10 PM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 14
Time spent in forums: 2 h 20 m 59 sec
Reputation Power: 0
|
|
Thanks for the reply, this is what I have now:
Code:
Original
- Code |
|
|
|
<form method="POST" target="newWindow" onSubmit="window.open('send.php?subscribe=1', 'newWindow','width=300,height=150,'+'status=no,toolbar=no,menubar=no')">
<input type=text name=email size=27>
<input class=button type="image" src="images/submit.jpg">
</form>
Then on the popup I have this:
Code:
Original
- Code |
|
|
|
$email = $_POST["email"];
$subscribe = $_POST["subscribe"];
echo $email $subscribe;
However when I submit the form all that happens is the pop up open with the original page and not the intended popup.
I am confused!
Thanks,
Rob.
|

March 14th, 2006, 05:29 PM
|
 |
CSS & JS/DOM Adept
|
|
Join Date: Jul 2004
Location: USA
|
|
You need to use the action attribute of form.
Code:
<form method="POST" action="send.php?subscribe=1" target="newWindow" onSubmit="window.open('', 'newWindow','width=300,height=150,'+'status=no,toolbar=no,menubar=no')">
|

March 14th, 2006, 05:45 PM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 14
Time spent in forums: 2 h 20 m 59 sec
Reputation Power: 0
|
|
|
Thanks guys, you're stars but it does not take me to telll you that!
I had been working on this for ages, all working great now.
Many thanks!
Rob.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|