Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pop up window and form data problem 1

Status
Not open for further replies.

levidyllan

Programmer
Aug 31, 2006
7
GB
i have this form that opens up a window when clicked and i want to pass the form details across to it, but as i am using Javascript to open the window its not working now.

heres the script code:
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=1,width=450,height=500,left = 362,top = 134');");
}
</script>

heres the form code:
Code:
<form method="post">
		<input type="hidden" name="link" value="<? $link ?>" />
		<input type="hidden" name="code" value="<? $code ?>" />
		<input type="hidden" name="codea" value="<? $codea ?>" />
		<input type="hidden" name="codea" value="<? $detail ?>" />
		<p><input type="button" value="Open the Popup Window" onClick="javascript:popUp('updatemain.php')"></p></form>

but the post effect wont work now, i am using on the other page
Code:
 $var=$_POST['link']; etc

but nothing its not picking up the form details ect
 
you will need to switch to a GET method, and incorporate the form field names and values in the query string.

this is because you are not submitting the form, but rather just opening a window.

you could also set the target of the form to "_blank" and then use a regular submit button, and continue using the POST methodology in the popup window.



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
how can i then control the size of the new _blank window if possible

thanks for the reply earlier
 
thank you will give it ago and hopefully not need to come back to this thread
 
i have used the
<form target="_blank" method="post" action="page.php">
method and although the whole thing works i cannot get the new/pop up page to size so if any one knows how to do this of where to place the code I would be much appreciated

thanks
 
think i am getting there slowly.

is there away like in JS to not show the men, scroll, etc so its just a frame

with the method above

<body onload="window.resizeTo(200,200);">


thank you so far
 
thanks will look for the holy grail, thanks so far, well off to bed, tis morning now :)
 
well i have help with this from bill poster(another forum), so thought i would share it with you:

Bill Posters said:
[*]Set up the form with a target attribute as per usual.
[*]Use the form's onsubmit event to intercept the form submittal process.
[*]The js creates the sized and positioned window using the same var name that is used in the form element's target attribute.
This will establish a popup window of the name used in the target attribute.
[*]Return true.
[*]The browser will then continue to handle the form as normal.
[*]It'll look around for a window of the target name, find it (it's the newly created popup window) and use it to display the form handler document.
[/list]

e.g.…

page.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>test</title>
	<script type="text/javascript">

	function formWin(url) {

		var winW = 200;
		var winH = 300;

		var winX = (screen.availWidth - winW) / 2;
		var winY = (screen.availHeight - winH) / 2;

		var feat = 'left='+winX+',top='+winY+',width='+winW+',height='+winH+',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1'

		var formWin = window.open(url,'formWin',feat);

		return true;

	}

	</script>
</head>
<body>

<form action="form.php" method="post" target="formWin" onsubmit="return formWin(this.action);">
<fieldset>

	<label>Name <input type="text" name="username" id="username" /></label><br />
	<label>Age <input type="text" name="userage" id="userage" /></label><br />
	<input type="submit" value="Submit" />

</fieldset>
</form>

</body>
</html>

form.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>Form Handler</title>
</head>
<body>

<p>
	Name is: <?php echo $_POST['username']; ?><br />
	Age is: <?php echo $_POST['userage']; ?>
</p>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top