SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Apr 17, 2007, 06:17 #1
- Join Date
- May 2004
- Location
- Scandinavia
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Open and close DIV area with JS and PHP
Hi everyone!
I have this simple Javascript to open and close div areas.
<script language="javascript" type="text/javascript">
function showDiv(theDiv) {
var elem = document.getElementById(theDiv);
elem.style.display = (elem.style.display == "none")? "" : "none";
}
</script>
Now I want to be able to open a div area, when sending a GET, eg /file.php?showDiv=5642
I have several divs on the same page, and when entering this page from special link, I want to be able to open that div area. Based on id.
Is that possible? Hope tou understand what I mean...
Thanks!
-
Apr 17, 2007, 07:34 #2
- Join Date
- Apr 2007
- Posts
- 813
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
do you have the code where you attach your showDiv function, is it bind to a certain object closure?
-
Apr 17, 2007, 10:42 #3
- Join Date
- May 2004
- Location
- Scandinavia
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
This is what I have
<div id="<?php echo($row['id']); ?>" style="display:none;>Some Text bla bla</div>
<a href="#" onclick="showDiv('<?php echo($row['id']); ?>');return false;">Show</a>
Thanks
-
Apr 17, 2007, 11:08 #4
- Join Date
- Nov 2006
- Posts
- 99
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi!
Try to put on your page where divs are something like this:
PHP Code:<?
if($_GET) {
if($_GET['some id which tells the page which div to show']) echo"<script type='text/javascript'>showDiv(div to show);</script>";
}
?>
Hope this helps.
-
Apr 17, 2007, 12:19 #5
- Join Date
- Nov 2006
- Posts
- 99
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry, it should be like this:
PHP Code:<?
if($_GET) {
if($_GET['your id']=='value which tells the page which div to show') echo"<script type='text/javascript'>showDiv(div to show);</script>";
}
?>
-
Apr 17, 2007, 22:47 #6
Bookmarks