I just added the below code to my site:
Then called it here:
It works, but if I click one item and don't close it, then click the second item, both will be displayed. I'd like to have the one item/div close when the other is opened. This isn't my code, I copied it from an open source and then modded it. Any help on this would be most appreciated!
Code:
<script language="JavaScript" type="text/javascript">
function showDiv(){
if(document.getElementById('showDiv').style.display == 'none'){
document.getElementById('showDiv').style.display = 'block';
}else{
document.getElementById('showDiv').style.display = 'none';
}
}
</script>
<script language="JavaScript" type="text/javascript">
function showDiv2(){
if(document.getElementById('showDiv2').style.display == 'none'){
document.getElementById('showDiv2').style.display = 'block';
}else{
document.getElementById('showDiv2').style.display = 'none';
}
}
</script>
Then called it here:
Code:
<span style="cursor:pointer;width:112px;height:50px;" onclick="showDiv();"><img src="/images/siteinfo.png"></span><span style="cursor:pointer;width:164px;height:50px;" onclick="showDiv2();"><img src="/images/anoucements.png"></span>
<div id="showDiv" style="display:none;">
<b>You have reached my new site!</b>
</div>
<div id="showDiv2" style="display:none;">
{section name=news_loop loop=$news max=5}
<table cellpadding='0' cellspacing='0' align='center' width='100%'>
<tr><td align=center><b> {$news[news_loop].announcement_subject}</b><br><i>{$news[news_loop].announcement_date}</i><br> {$news[news_loop].announcement_body}</td></tr>
<tr><td><center><img src="./images/line_small.gif"></center></td></tr>
</table>
{/section}
</div>
It works, but if I click one item and don't close it, then click the second item, both will be displayed. I'd like to have the one item/div close when the other is opened. This isn't my code, I copied it from an open source and then modded it. Any help on this would be most appreciated!