Forum Moderators: coopster & phranque

Message Too Old, No Replies

Passing variable to a page in a frameset

         

lizard

3:15 pm on Jun 21, 2002 (gmt 0)

10+ Year Member



Can anybody tell me how I pass a variable in PHP from a page
in a pop-up window to a page in a frameset?

thanx

Pete

Knowles

3:18 pm on Jun 21, 2002 (gmt 0)

10+ Year Member



[webmasterworld.com...]

Take a look at that thread lizard see if that is what you are needing.

lizard

4:45 pm on Jun 21, 2002 (gmt 0)

10+ Year Member



Passing from one page to another is no problem but
passing it to a page in a frameset just does not
work, I even tried to pass the varialbe and then
force it back into the frame, no go

Knowles

4:50 pm on Jun 21, 2002 (gmt 0)

10+ Year Member



hmmm I am not sure why it wouldnt unless its due to the pop up window not closing. When you link back to it and put target="leftside" is it not doing it? I am not that familur with frame sets all that much I never liked them much.

Can you link from the popup to that fameset with out passing the var? Or can you not get either to work?

jatar_k

5:01 pm on Jun 21, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



passing from the popup to the frame is the same as passing page to page.

Are you using get or post?

I think the offending snippet of code would help me understand a bit better or a sticky with the url.

ergophobe

6:52 pm on Jun 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Lizard, here's some code that does exactly that. If you need help, I can explain it. In brief, this is a modification I wrote for osCommerce so that it could have a product-image popup that would give thumbnails in one frame and a single enlargement in the other. There are lots fo calls to functions that I don't give, but the only one you should need to know about is tep_href_link which is

tep_href_link($url, $string_for_get_params).


if ($HTTP_GET_VARS['zoomID']) {
$product_query = "SELECT m.products_id, pd.products_name"
. " FROM " . TABLE_MEDIA . " m, " . TABLE_PRODUCTS_DESCRIPTION . " pd"
. " WHERE media_id = '" . $HTTP_GET_VARS['zoomID']
. "' AND m.products_id=pd.products_id AND language_id = '" . $languages_id . "'";
$product_result = tep_db_query($product_query);
$product = tep_db_fetch_array($product_result);
$pID = $product['products_id'];
$link_param = "zoomID=" . $HTTP_GET_VARS['zoomID'];
} elseif ($HTTP_GET_VARS['pID']) {
$pID = $HTTP_GET_VARS['pID'];
$link_param = "pID=" . $HTTP_GET_VARS['pID'];
$product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $pID . "' and language_id = '" . $languages_id . "'");
$product = tep_db_fetch_array($product_query);
} else {
// echo "pID not defined";
}


$popup_dims = tep_get_popup_dims($pID);
?>


<html>
<frameset cols="*, <?php echo $popup_dims['right_frm_width']; ?>" class="imgPopup">
<?php
echo "<frame src=\"" . tep_href_link(FILENAME_MEDIA_ZOOM, $link_param) . "\" name=\"" . FRAME_MEDIA_ZOOM . "\">\n";
echo "<frame src=\"" . tep_href_link(FILENAME_MEDIA_THUMBNAILS, "pID=" . $pID) . "\" name=\"" . FRAME_MEDIA_THUMBNAILS . "\">\n";
?>
</frameset>
</html>

And then the one frame looks like


<html>
<body>
<table>
<tr>
<td align="center" valign="top">
<br>
<?php
$product_media = tep_get_all_thumbnails($HTTP_GET_VARS['pID'], $languages_id);
echo $product_media["html"];
?>
</td>
</tr>
</table>
</body>
</html>

Sorry to post so much, but I hope it helps

Tom

lizard

7:02 pm on Jun 21, 2002 (gmt 0)

10+ Year Member



I have a file in a pop-up called upload.php.
On submit it uploads an image to the server and
then opens a frameset, image.htm containing
the frames right.htm and left.php. I want to pass the variable
'dirname' from upload.php to left.php
Doing it like 'left.php?dirname=$myVariable' works fine but
then left.php is not in the frame anymore.
Somehow I have to pass it to left.php while calling the
frameset (image.htm).

ergophobe

10:17 pm on Jun 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Simple, assuming I understand now where your problems is. You just need to follow the steps.

=============
upload.php
-----------
<?php
echo "<form action=\"myframe.php?dirname=$myVar\">"
?>

===============
myframe.php
----------------

<frameset>
<?php
echo "<frame src=\"left.php?dirname=" . HTTP_GET_VARS['dirname'] . "\">\n";
echo "<frame src=\"right.php\">\n";
?>
</frameset>

============
left.php
------------
<?php
upload_dir = HTTP_GET_VARS['dirname']
?>

Is that what you mean? You have to pass the variable twice - once to the frameset, once to the frame. Use HTTP_GET_VARS or the newer nomenclature depending on which PHP you're running.

Tom