[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

showing, hiding, and not hiding

Posted on 2005-04-14
5
Medium Priority
?
364 Views
Last Modified: 2010-08-05
I must be going wrong somewhere.

This positions some div's on top of links, and then closes them from links. The close part is clearly where I've messed up here...

Can you offer some advice?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">

table#teams
{
      position:absolute;
      top:220px;
      left:123px;
      border:none;
}

.bio
{
      position:absolute;
      top:220px;
      left:123px;
      display:none;
      width:642px;
      background-color:#ffffff;
}

</style>
</head>
<body>
<script type="text/javascript">
<!--
function showBIO(n)
{
      for(var i = 1; i<=11; i++)
      {
            document.getElementById('bio'+i).style.display = (i==n)?'block':'none';
      }
}
function hideBIO(n)
{
      for(var i2 = 1; i2<=11; i2++)
      {
            document.getElementById('bio'+i2).style.display = (i2==n)?'none':'block';
      }
}      
//-->
</script>
      
<table id="teams" cellspacing="0" cellpadding="10">
      <tr>
            <td><a href="javascript:showBIO(1)">John Doe 1</a><br>Consultant</td>
            <td><a href="javascript:showBIO(2)">John Doe 2</a><br>Consultant</td>
            <td><a href="javascript:showBIO(3)">John Doe 3</a><br>Consultant</td>
      </tr>
</table>
      
<div class="bio" id="bio1">
      <h2>John Doe 1, Consultant</h2>
      <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.</p>
      <p style="text-align:center;"><a href="javascript:hideBIO(1)">close</a></p>
</div>

<div class="bio" id="bio2">
      <h2>John Doe 2, Consultant</h2>
      <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.</p>
      <p style="text-align:center;"><a href="javascript:hideBIO(2)">close</a></p>
</div>

<div class="bio" id="bio3">
      <h2>John Doe 3, Consultant</h2>
      <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.</p>
      <p style="text-align:center;"><a href="javascript:hideBIO(3)">close</a></p>
</div>

</body>
</html>


Thanks,
Sean
0
Comment
Question by:seanpowell
5 Comments
 
LVL 32

Accepted Solution

by:
Batalf earned 2000 total points
ID: 13785234
It doesn't look like you need more than this simpel showBio() and hideBio() function:

<script type="text/javascript">
<!--
function showBIO(n)
{
     document.getElementById('bio'+n).style.display = 'block'
}
function hideBIO(n)
{

     document.getElementById('bio'+n).style.display = 'none'
}    
//-->
</script>
0
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 13785254
Sean,

Am I missing something?


<script type="text/javascript">
<!--
function showBIO(n)
{
    document.getElementById('bio' + n).style.display = 'block';
}
function hideBIO(n)
{
    document.getElementById('bio' + n).style.display = 'none';
}    
//-->
</script>
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13785258
How shud the script suppose to work?
0
 
LVL 31

Author Comment

by:seanpowell
ID: 13785272
>>Am I missing something?

Yes - Batalf's comment :-)

Thanks so much, you guys are wonderful
Sean
0
 
LVL 25

Expert Comment

by:archrajan
ID: 13785282
Sean,

By the way thats a nice way to show div , looks great!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question