Forum Moderators: coopster

Message Too Old, No Replies

Parsing variables all over the place

         

Robert Poole

1:13 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



Okay, so I've been given a new mission whether or not I chose to accept it. Eventually it's going to turn into a mortgage calcultor but I haven't bothered to get into any calculations at this point. Right now I'm more worried about parsing variables between frames... or even between windows.

I've taken a primtive screendump to try and explain my problem:

So in the example the main window displays the "magic number" and the calculator is launched. In this calculator the user can input a new "magic number", and what I want is for this number to be parsed back to the main page.

Further more I would love it if the magic number on the main page updated when the submit button in the popup is pressed.

I don't even know if this is remotely possible in PHP or if it would require javascript, but I'll take any suggestions at this point.

Thanks for reading!

[edited by: jatar_k at 1:19 pm (utc) on June 18, 2007]
[edit reason] no urls thanks [/edit]

mooger35

5:22 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



I have a processing page that I use after the form is submitted...

I add a close page link to that page.

<a href="javascript:opener.location.reload(true); self.close();">Close Window</a>

That will reload the page that opened the popup.

As for transferring the info... maybe using sessions?

[edited by: eelixduppy at 2:03 am (utc) on June 19, 2007]
[edit reason] disabled graphic smile faces [/edit]

mooger35

6:35 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



I think this would work as well... then you could access your new number ($magic_num) with $_GET

<a href="#" ONCLICK="opener.location='yourpage.php?number=<? echo $magic_num;?>';self.close();">Close Window</a>

/untested

mooger35

7:02 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



Hope this is what you were looking for as it peaked my interest. ;-)

mainpage.php:

<script>
function openComment(url) {
popUpWin = window.open(url,'Comments','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=500,height=300');
if (navigator.appName == 'Netscape') {
popUpWin.focus();
}
}
</script>

<p><a href="javascript:openComment('popup.php')">Select a number</a></p>

<?
if (isset($_GET['number'])){
$magic_num = $_GET['number'];
echo "<p>Magic Number: $magic_num</p>";
}
?>

popup.php:

<form name="input" action="popup.php"
method="post">
Magic Number:
<input type="text" name="number">
<input type="submit" value="Submit">
</form>
<?
if(isset($_POST['number'])){

$magic_num = $_POST['number'];

if(!is_numeric($magic_num)) {
echo "<p>INVALID NUMBER!</p>";
DIE();
}
?>
<p>You have selected <? echo $magic_num;?>.</p>

<p><a href="#" ONCLICK="opener.location='mainpage.php?number=<? echo $magic_num;?>';self.close();">Click here</a> to calculate.</p>
<?
}
?>

[edited by: eelixduppy at 2:04 am (utc) on June 19, 2007]
[edit reason] disabled smile faces [/edit]

Robert Poole

8:43 am on Jun 19, 2007 (gmt 0)

10+ Year Member



Wow, that's awesome work mooger! You really went to town on the solution!

I can definately use this solution in building my mortgage calculator! Thanks for your thorough and monumentally helpful input.

PS

Sorry for putting a url in my first post Jatar.

jatar_k

12:38 pm on Jun 19, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



not a problem Robert Poole and Welcome to WebmasterWorld