passing variables via forms

D

don

I have a form which when the user clicks the submit button it calls another
page which generates some stuff - however, on this second page I have an
iframe which generates a table which needs the variables from the first page
passed to it - is there a way to do this?
 
T

Toby Inkster

don said:
I have a form which when the user clicks the submit button it calls another
page which generates some stuff - however, on this second page I have an
iframe which generates a table which needs the variables from the first page
passed to it - is there a way to do this?

Yes. Let's call the first page "pagea.html", the second page "pageb.php"
and the iframe thats inserted into the second page "iframe.php". And the
data that we're passing around is called "query".

Examples use PHP, but the same basic idea will work in other server-side
languages too.

================ pagea.html ================
<form action="pageb.php" method=get>
<div>
<input name=query>
<input type=submit>
</div>
</form>
============================================

================ pageb.php =================
<?php
$query = ($_GET['query']?$_GET['query']:'BLANK');
$qurl = htmlentities(urlencode($query));
?>

<p>Query was <tt><b><?=$query?></b></tt>.</p>

<iframe name=foo height=100 width=200 src="iframe.php?query=<?=$qurl?>">
Your browser does not support <code>iframe</code>.<br>
Please go to the <a href="iframe.php?query=<?= $url ?>">page</a>
manually.
</iframe>
============================================

================ iframe.php ================
<?php
$query = ($_GET['query']?$_GET['query']:'BLANK');
?>
<p>Query was <tt><b><?=$query?></b></tt>.</p>
============================================
 
A

ANDERS FLODERUS

don said:
I have a form which when the user clicks the submit button it calls another
page which generates some stuff - however, on this second page I have an
iframe which generates a table which needs the variables from the first
page
passed to it - is there a way to do this?

One method that ought to work is using frames and javascript.
If this is acceptable to you, you can have the scripting code with
variables in the top (frameset) frame, load the different pages in
a single frame and access the top frame variables from there.

Good luck
Anders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top