...

View Full Version : How do you post a variable to a pop-up window?



soma56
12-24-2010, 05:00 PM
I can't seem to figure out how to post a variable to a javascript pop-up window. I'm trying to get a the users input to post directly to the URL.

For example:



<!--Pop-up-->
<script type="text/javascript">
<!--
function expo() {
window.open( "export.php?&export=<?PHP $myvar = $_POST['exportthis']; echo $myvar; ?>", "myWindow",
"status = 1, height = 300, width = 300, resizable = 0" )
}
//-->
</script>

<form action="" method="post"><input type=text value="pass-this-variable" name="exportthis">
<input type=button value="Export" name="Exp" onClick="expo()">
</form>



Any suggestions?

DJCMBear
12-24-2010, 05:06 PM
Like this



<!--Pop-up-->
<script type="text/javascript">
<!--
function expo(o) {
var et = document.getElementById(o);
if(et) {
window.open( "export.php?export="+et.value, "myWindow", "status = 1, height = 300, width = 300, resizable = 0");
}
}
//-->
</script>

<form action="" method="post"><input type=text value="pass-this-variable" name="exportthis" id="exportthis">
<input type=button value="Export" name="Exp" onclick="expo('exportthins');">
</form>

soma56
12-24-2010, 05:25 PM
That's the right idea but it doesn't work. My button does nothing now. Possible mistype in code?

DJCMBear
12-24-2010, 05:32 PM
My fault sorry, there was a typo.

Change this.
onclick="expo('exportthins');"
To this
onclick="expo('exportthis');"

soma56
12-24-2010, 05:45 PM
My fault sorry, there was a typo.


No need to be sorry and I appreciate your help on Christmas eve. It sure goes to show the dedication of some of us coders. That's exactly what I needed. Thank you.

Perhaps your thinking about joining the gym in the new year as I am? :)
thins');"

DJCMBear
12-24-2010, 05:48 PM
Perhaps your thinking about joining the gym in the new year as I am? :)

Lol well after the christmas food I may need to :p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum