Page 1 of 1

[SOLVED] refresh an iframe...

Posted: Wed Oct 06, 2004 7:56 am
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!!!

reset the src.

Posted: Wed Oct 06, 2004 8:33 am
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.

Posted: Wed Oct 06, 2004 8:55 am
by feyd
yes, this is done through Javascript. You can do

Code: Select all

top.box.document.location.reload()
I believe.

Posted: Wed Oct 06, 2004 10:19 am
by kevin7
hmm, ur code is not working...
em, what i suppose to do then?

Posted: Wed Oct 06, 2004 10:25 am
by feyd
could need

Code: Select all

top.framesї index of the frame ].location.reload()
or similar..

Posted: Wed Oct 06, 2004 10:28 am
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

Posted: Wed Oct 06, 2004 10:42 am
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;

Posted: Wed Oct 06, 2004 10:08 pm
by kevin7
thx guys! it is works now!