Creating Dynamic Div's
Hey, basically what I want to do is have a nav bar/image that when a link is clicked on, it opens up a div inside the same window, with the appropriate text and title. I'm not sure of how to go about the onclick sort of thing, but I have an idea of how to do the appropriate text and title...
<?php
$title = ([clicked item]title);
$page = [clicked item];
include ('$title.php');
include ('$page.php');
?>
where $title.php and $page.php would be individual pages and titlepages, setting up the div to display on the page.
How do I do the onclick script running, as well as passing the clicked link name to other variables?
Thanks.
Mark Hensler posted this at 02:48 — 16th February 2004.
He has: 4,048 posts
Joined: Aug 2000
That is DHTML (with JavaScript). So I'm moving to Web Page Authoring.
I'm not sure about putting external web pages into a div. But you can with an IFrame.
Mark Hensler
If there is no answer on Google, then there is no question.
kb posted this at 03:44 — 16th February 2004.
He has: 1,380 posts
Joined: Feb 2002
I know you can do it with an IFrame...but I've also done it with a div before:
/* Stylesheet */
div.window {
position:absolute;
top:180;
left:200;
width:175;
height:190;
z-index:50;
padding:2px;
border: #000000 2px solid;
background-color:#000000;
}
div.menu {
align: right
background-color: #CCCCCC;
}
/* HTML */
<div id="weather" class="window">
<div align="right" class="menu"><!-- title here --><br />
</div>
<!-- text here -->
</div>
So how would I do this passing with Javascript/DHTML and it is cross-browser?
Abhishek Reddy posted this at 05:03 — 16th February 2004.
He has: 3,348 posts
Joined: Jul 2001
Hm. You can't invoke a server-side script using client-side Javascript without sending a HTTP request somehow. This means either using an iframe or refreshing the current page. What you can do is load up *all* the information you can possible display into hidden objects, or JS variables and display them as needed. Another trick would be to use an unseen iframe to load data served up by your PHP script into its internal DOM and grab what you need, from your main context.
It is possible to send a request by setting an image's (or other object's) src to your PHP file, but I forget how data is returned.
kb posted this at 16:52 — 16th February 2004.
He has: 1,380 posts
Joined: Feb 2002
OK well, how about this...use an IFrame and then have the target of the link be the IFrame, which becomes visible onclick of link, having the content of the IFrame as the href of the link...
Could you do such as (this is a pre-design thought, have nothing to test with):
<a href="/content/home.html" target="IFrame" onclick()="run">...img...</a>
<iframe id="IFrame" src="" visibility="false"></iframe>
where onclick() toggles the visibility
Abhishek Reddy posted this at 00:52 — 17th February 2004.
He has: 3,348 posts
Joined: Jul 2001
iframe.hide { display: none; }
iframe.show { display: block; }
<a href="money.php" target="money" onclick="document.getElementById('money').style.class='show';">Show me the money</a>
<iframe class="hide" id="money"></iframe>
Then you'll have to have a mechanism to hide, probably. It's looks messy to me. There ought to be a better way to do it -- do you really need this? What's the actual content like? There might be a better solution, depending on the content.
kb posted this at 01:23 — 17th February 2004.
He has: 1,380 posts
Joined: Feb 2002
here's a "graphical" representation of what I want:
<?php
|------------------------------------------- |
| ------------------|
| | [content] |
| [img nav] | |
| |----------------|
| |
|-------------------------------------------|
?>
Wow, that looks terrible, but you get what I mean? The contents will be PHP/HTML...mostly text with maybe a few pictures, but no graphics or fancy JS.
Abhishek Reddy posted this at 01:29 — 17th February 2004.
He has: 3,348 posts
Joined: Jul 2001
Is there a problem with having the page reload?
Also, the content would be a better starting point than the design for this sort of thing.
kb posted this at 01:49 — 17th February 2004.
He has: 1,380 posts
Joined: Feb 2002
Yea, I would prefer that the main page doesn't reload, but don't have a problem with the ILayer or div refreshing...
I do have content laid out, this is a redesign of another website. These are preliminary explorations into finalization of a design...meaning I'm trying to figure out how to do what is wanted. The nav (main page...the "img nav") is alot of complicated graphics design, which I don't want to do until the project is finalized with design (there are two options for the image).
So...I have content, just not coded.
andy206uk posted this at 09:12 — 17th February 2004.
He has: 1,758 posts
Joined: Jul 2002
IF you have dreamweaver or fireworks then they have "wizards" that do that for you using dhtml.
kb posted this at 02:01 — 18th February 2004.
He has: 1,380 posts
Joined: Feb 2002
na, sorry. hand code it all.
JeevesBond posted this at 08:24 — 18th February 2004.
He has: 3,956 posts
Joined: Jun 2002
Yeah, best way to do it Kyle... Pesky wizards
You could do all this with a div inside a link and the :hover psuedo-class of that link (CSS) - well it works in theory, I haven't tried it yet
a Padded Cell our articles site!
kb posted this at 00:29 — 19th February 2004.
He has: 1,380 posts
Joined: Feb 2002
I'm sorry, but I just won't use one. I hand code...not "click-and-drag"
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.