CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346

    Problem with objects

    I'm working with the visibility of divs. I've tried to come up with a generic function i can pass the name of a div to. Basically the function should show that div (visibility=visible) and hide the one that was visible (it's saved in a variable;visiblility=hidden). I think i've worked out syntax bugs...and sort of made it cross browser to an extent, but I'm having trouble with "a required object". Here's the script and implementation:
    Code:
    var toThis;
    var wasThis="null";
    var theDiv;
    			function switchTo(toThis)
    			{
    				if (document.all)
    				{
    					theDiv=document.all(toThis).style;
    				}
    				else if (document.GetElementById)
    				{
    					theDiv=document.GetElementById(toThis).style;
    				}
    				theDiv.visibility="visible";
    				if (wasThis!="null")
    				{
    					wasThis.visibility="hidden";
    				}
    				wasThis=theDiv;
    			}
    
    ...
    
    			<div id="aboutMe">
    				This is info about Me
    			</div>
    			<div id="aboutSchool">
    				This is info about the school
    			</div>
    				<a href="#" class="barlink" onclick="javascript:switchTo(aboutMe); return false;">
    					About Me
    				</a>
    				<br>
    				<a href="#" class="barlink" onclick="javascript:switchTo(aboutSchool); return false;">
    					About School
    				</a>
    i've also attached the whole source in .txt format

    thanks for any help you can give me
    Attached Files Attached Files

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

  2. #2
    Join Date
    Aug 2002
    Location
    Reykjavik, Iceland
    Posts
    201
    See my response to your thread "DHTML problemo"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured