homepage Welcome to WebmasterWorld Guest from 54.205.254.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Javascript Hide/Show Div inside PHP Tag
mysql, php, javascript, div, reload, show, hide
Petervn




msg:4461952
 8:31 am on Jun 6, 2012 (gmt 0)

I am hiding/showing divs using Javascript. I have added php pagenitation to the page and when I browse through the pagenitation, it jumps back to the first div and not the currently viewed div. Any suggestions how to get the Javascript to work inside the php tags?
Herewith the coding:

JAVASCRIPT INSIDE HEADER:
//show div and hide another
function showHide(d)
{
var onediv = document.getElementById(d);
var divs=['content1','content2','content3','content4','content5'];
for (var j=0;ji<divs.length;j++)
{
if (onediv != document.getElementById(divs[j]))
{
document.getElementById(divs[j]).style.display='none';
}
}
onediv.style.display = 'block';
}

NAVIGATION:
<!--navigation menu-->
<div class="menu2">
<a href="javascript:showHide('content1');">1</a>
<a href="javascript:showHide('content2');">2</a>
<a href="javascript:showHide('content3');">3</a>
<a href="javascript:showHide('content5');">5</a>
</div>
<!--end navigation menu-->

THE ACTUAL DIV:
<div class="topcontent" id="content5" style="display:none">

AND PAGINATION PHP:
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage' 'javascript:showHide('content5');'><</a> ";

</div>

I cannot get the Javascript to work inside the PHP tag
Please help

 

rocknbil




msg:4462130
 5:38 pm on Jun 6, 2012 (gmt 0)

Ooops, already answered here [webmasterworld.com]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved