[SOLVED] refresh an iframe...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

[SOLVED] refresh an iframe...

Post by kevin7 »

em, i've two iframe,

first iframe (called "sform") is a form that allow user to submit opinion
second iframe (called "box") is display all the opinion
(something like chatbox)

the problem is, after i submit the form, i want to refresh the second iframe to update the information...

how can i do that, can i use php? or javascript?

tq!!!
Last edited by kevin7 on Wed Oct 06, 2004 10:09 pm, edited 1 time in total.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

reset the src.

Post by phpScott »

you will have to reset the src tag of the second Iframe.
using JS you can trigger an event from the returning 1st frame to reset the source of the second iframe.
you will have to do some messy variable passing, but it can be done.
If you need more help, repost and I can share some of my ugly code to get it done with you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yes, this is done through Javascript. You can do

Code: Select all

top.box.document.location.reload()
I believe.
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

hmm, ur code is not working...
em, what i suppose to do then?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

could need

Code: Select all

top.framesї index of the frame ].location.reload()
or similar..
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

in your form iframe do some kind of trigger like

Code: Select all

<body onload="setboxsrc()">
then create a javascript function like

Code: Select all

function setboxsrc()
&#123;
parent.document.getElementById('box').src="chatbox.php";
&#125;
where 'box' is the id of your second iframe.

the parent refers to the parent page of the Iframe then the rest is straight forward.

phpScott
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

&lt;?php session_start();

$_SESSION&#1111;'counter'] = (!isset($_SESSION&#1111;'counter']) ? 0 : intval($_SESSION&#1111;'counter']) + 1);

if(!isset($_GET&#1111;'frame']))
{
echo &lt;&lt;&lt;STOP
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;main page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
{$_SESSION&#1111;'counter']}&lt;br /&gt;
&lt;iframe name="sform" src="{$_SERVER&#1111;'SCRIPT_NAME']}?frame=1" width="200" height="200"&gt;iframe&lt;/iframe&gt;
&lt;iframe name="box" src="{$_SERVER&#1111;'SCRIPT_NAME']}?frame=2" width="200" height="200"&gt;iframe&lt;/iframe&gt;
&lt;/body&gt;
&lt;/html&gt;
STOP;
}
elseif($_GET&#1111;'frame'] == 1)
{
echo &lt;&lt;&lt;STOP
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;main page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
sform&lt;br /&gt;
{$_SESSION&#1111;'counter']}&lt;br /&gt;
&lt;a href="javascript:top.frames&#1111;'box'].document.location.reload()"&gt;reload other iframe&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
STOP;
}
else
{
echo &lt;&lt;&lt;STOP
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;main page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
box&lt;br /&gt;
{$_SESSION&#1111;'counter']}&lt;br /&gt;
&lt;/body&gt;
&lt;/html&gt;
STOP;
}
?&gt;
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

thx guys! it is works now!
Post Reply