The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
Display/Hide Div
Discuss Display/Hide Div in the JavaScript Development forum on Dev Shed. Display/Hide Div JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 13th, 2004, 12:05 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 28
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Display/Hide Div
Hello All,
I'm running into a little trouble trying to display a hidden div... I could swear that I had done this exact same thing before and it worked fine...
Quote:
function DisplayNav(in_strName, in_obj)
{
if (strCurrentDisplay != in_strName)
{
strCurrentDisplay = in_strName;
document.getElementById('Practice').style.display='none';
document.getElementById('Tournaments').style.display='none';
document.getElementById('Archive').style.display='none';
document.getElementById('Photos').style.display='none';
document.getElementById(in_strName).style.display='';
}
} |
Hiddend Div
Quote:
<div id="Photos" style="DISPLAY: none">
<table border="0" width="800" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<table border="0" width="100%" cellspacing="0" cellpadding="3">
<tr>
<td width="100%"><p align="center"><b><font face="Arial" size="5">Team Photos</font></b></td>
</tr>
<tr>
<td width="100%">soon...</span></td>
</tr>
</table>
</td>
</tr>
</table>
<hr noshade size="5" width="800" align="left">
</div> |
The link to display the Div (and hide others)
Quote:
<A href="javascript:DisplayNav('Photos')">Practice Schedule</A> |
The error I get is...
error object expected.
Any help is much appreciated.
~Thanks, Jim
|

December 13th, 2004, 12:10 PM
|
 |
Cunning Linguist
|
|
Join Date: Jul 2003
Location: I used to live at home, now I stay at the house
|
|
First of all, this...
Code:
document.getElementById(in_strName).style.display='';
...should be like this...
Code:
document.getElementById(in_strName).style.display='block';
Secondly, what is giving the error? What does the FireFox js debugger tell you? Or if you are using IE, where in the code is the error?
|

December 13th, 2004, 12:21 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 28
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Hey ChiefWigs1982,
I'm using IE, and I get the error on the HREF...
Code:
DisplayNav('Practice')
Your help is much appreciated.
~Thanks again, Jim
|

December 13th, 2004, 12:29 PM
|
 |
Cunning Linguist
|
|
Join Date: Jul 2003
Location: I used to live at home, now I stay at the house
|
|
|
I can't see anything wrong with your href... Do you have a link to your code?
Object expected is usually IE's way of telling you it can't find the function you are looking for. JS is ub0r case-sensitive, so make sure the function name is the same as the one you are calling...
|

December 13th, 2004, 01:19 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 28
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Here is the code...
code
I appreciate you taking a look. It has me stumped.
~Thanks, Jim
|

December 13th, 2004, 01:35 PM
|
 |
Cunning Linguist
|
|
Join Date: Jul 2003
Location: I used to live at home, now I stay at the house
|
|
Why are you using this script tag?
Code:
<script language="JavaScript" for="window" event="onload">
Change your whole script block to this...
Code:
<script language="JavaScript">
var strCurrentDisplay='';
function DisplayDIV(in_strName)
{
document.getElementById('Practice').style.display='none';
document.getElementById('Tournaments').style.display='none';
document.getElementById('Archive').style.display='none';
document.getElementById('Photos').style.display='none';
document.getElementById(in_strName).style.display='block';
}
</script>
|

December 13th, 2004, 01:48 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 28
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Thanks ChiefWigs1982, that worked like a charm! Your help is much appreciated.
~Jim
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|