Page 1 of 1

displaying a php file inside a div.

Posted: Mon Sep 24, 2007 2:32 am
by jwaqa1
Hello everyone.
I have a slight problem. I am about 3 months new to php coding and am requesting an answer to the following.
Bascially i have php link that should display a php file within a div.

2 php files are being used. one as the index the other as the file to be loaded into the div i created.

This is the php code - index.php. this code is inside php start and finish conditions.
<a href=view_subCat.php?cat_Id=$cat_Id target= content><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>

This is the div where the view_subCat.php file need to be loaded - index.php - this code does not exist inside php start and close conditions
<div id="content" style="position:absolute; top:50; left:0; width:200; height:648; z-index:1; border: #000000 1px solid;background-color:none;"></div>

At the moment it is loading the view_subCat.php file in full view rather then inside the div i created. The div has an id called content that i use as a target. I have also tried
rel. However, after using either rel or target, the file loads the php in a new window or loads the file in full view of the index page where the div is coded.

Is there anything i can do to make sure it loads within the div's only?

you need ajax support ,or div contain iframe

Posted: Mon Sep 24, 2007 2:54 am
by phpsir
you need ajax support ,or div contain iframe

contract me 733905@gmail.com

Posted: Mon Sep 24, 2007 3:33 am
by aceconcepts
Not sure if this is what you are after but take a look: http://www.dynamicdrive.com/dynamicinde ... viewer.htm

Re: displaying a php file inside a div.

Posted: Mon Sep 24, 2007 9:20 am
by lnt
jwaqa1 wrote:Hello everyone.
<a href=view_subCat.php?cat_Id=$cat_Id target= content><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>
The attribute "target" of anchor element must be the name of some window.
In your case, use Ajax to get information from server and use DOM to fill div block

Posted: Mon Sep 24, 2007 11:55 am
by feyd
Make sure this works without Javascript enabled too, if you go the Ajax route.

Posted: Mon Sep 24, 2007 10:02 pm
by lafflin
Why Ajax? could you not use the <iframe> tag to display the content that you want in your <div>? The only reason that you would want to use Ajax is if the content within your <div> needed to be updated continuosly without refreshing the page. But then I could be missing something, I dunno.

Posted: Tue Sep 25, 2007 12:23 am
by lnt
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


If you don't like Ajax, use iframe
[syntax="html"]<a href="javascript:document.getElementById('content').src='view_subCat.php?cat_Id=$cat_Id'"><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>

<iframe id="content" style="position:absolute; top:50; left:0; width:200; height:648;border: #000000 1px solid;background-color:none;"></iframe> 
Try replace iframe with div ? It's OK?


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Sep 25, 2007 1:02 am
by mrkite
lnt wrote:If you don't like Ajax, use iframe

Code: Select all

<a href="javascript:document.getElementById('content').src='view_subCat.php?cat_Id=$cat_Id'"><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>

<iframe id="content" style="position:absolute; top:50; left:0; width:200; height:648;border: #000000 1px solid;background-color:none;"></iframe>
Try replace iframe with div ? It's OK?
For an iframe, instead of "id" you need to use "name" to reference it as a target.

So if you're going to use the above javascript with getElementById() keep it id="content" but if you want to use your original code of target="content" you need to make it name="content".

Thankyou

Posted: Tue Sep 25, 2007 1:19 am
by jwaqa1
Its working fine now Thankyou.

I modified my html file to use iframes.
Bascially i modified and used code from the http://www.dynamicdrive.com/dynamicinde ... viewer.htm example.

the following php code tells the javascript tabs to load the php files into the iframes.

<ul id="tablist"> print("<li><font color='#0066FF'><a class='current' href=view_subCat.php?cat_Id=$cat_Id onClick='return handlelink(this)'>"."$cat_Name"."</a></font></li>");</ul>

The Pages are loaded into the following iframe
<iframe id="tabiframe" src="sub Categories.htm" width="10%" height="80%"></iframe>

regards jwaqa1

Posted: Tue Sep 25, 2007 3:43 am
by aceconcepts
Pretty nice script eh