Closed Thread Icon

Topic awaiting preservation: passing variables to a new window (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23503" title="Pages that link to Topic awaiting preservation: passing variables to a new window (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: passing variables to a new window <span class="small">(Page 1 of 1)</span>\

 
Babamba
Paranoid (IV) Inmate

From: my mother
Insane since: Aug 2000

posted posted 09-30-2004 23:47

How do I pass variables from one page to a popup window using php? I want to be able to click on a link and have the variables passed to the resulting popup. Is there a better way to do it, without using php? I've searched the web in vain for a solution. Thanks in advance,

Spam is yummy
~babamba

(Edited by Babamba on 09-30-2004 23:57)

Hebedee
Paranoid (IV) Inmate

From: Maryland, USA
Insane since: Jan 2001

posted posted 09-30-2004 23:59

You could use a form tag and have hidden post variables. Simply "submit" to a new page.

[Edit:
I realized that may not be clear enough.

Using a <form action="post" method="yourpopup.html" target="_blank"> is for a default browser window.

Otherwise, Javascript will be necessary.
]

(Edited by Hebedee on 10-01-2004 00:05)

Babamba
Paranoid (IV) Inmate

From: here
Insane since: Aug 2000

posted posted 10-01-2004 00:37

How would I do it without a form? These are variables that I will declare on the parent.

~babamba
Spam is yummy

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 10-01-2004 02:59

Parent document-

index.php

code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>parent</title>


<?php
$foo="passed";
echo "
<script type='text/javascript' language='Javascript'>
function go(){
window.open('newpage.html','new','height=200px, width=200px'),
}
tryMe= new Object();
tryMe.speak='";
echo $foo . "'</script>";
?>

</head>
<body>
<a href="javascript:alert(tryMe.speak+' from parent');go()">howdy</a>
</body>
</html>



Pop-up document-

newpage.html

code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>newpage</title>
<script type="text/javascript" language="Javascript">
<!--
function speak(){
alert(window.opener.tryMe.speak + " to child");
}
//-->
</script>
</head>
<body onload="speak()">
<h2>This makes me feel smart!</h2>
</body>
</html>



Objects rule....

/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

(Edited by norm on 10-01-2004 03:00)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-01-2004 03:12

Um this is all well and good but you can also just pass the variables in the query string of the new winow url

<a href="something.php?variable1=something&variable2=something2" target="new">link</a>

or with a popup

window.open('something.php?variable1=something&variable2=something2','new','height=200px, width=200px'),

even without php you could parse the querystring with Javascript to get the variables



.:[ Never resist a perfect moment ]:.

(Edited by bitdamaged on 10-01-2004 03:14)

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 10-01-2004 03:16

ok....sure... Do it the easy way then. (lol)

I wish I would have thought of that.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-01-2004 17:55





.:[ Never resist a perfect moment ]:.

Babamba
Paranoid (IV) Inmate

From: here
Insane since: Aug 2000

posted posted 10-01-2004 23:27

bit, how do i call the variable then? I tried this:

code:
<a href='new.php?name=joe' target='new'>link</a>



new.php:

code:
<?php
print "$name";
?>



and it doesn't work. Where am i going wrong? Thanks,

~babamba
Spam is yummy

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 10-01-2004 23:36

why not looking the PHP documentation ?

Babamba
Paranoid (IV) Inmate

From: here
Insane since: Aug 2000

posted posted 10-02-2004 00:02

poi, i've seen that before, and I'm confused about exactly what they're talking about. And I don't see how to adapt their coding to fit my needs.

~babamba
Spam is yummy

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-02-2004 00:17

you always have to think about the way your php scripts receive their variables.
In this case, you're passing them via HTTP GET ( rfc->2616 ) - and would find them in $_GET['name'] (and no, the quotes are not optional).

So long,

->Tyberius Prime

« BackwardsOnwards »

Show Forum Drop Down Menu