[Javascript] Show and hide multiple div tags

Abyss - Information Info at Abyss.ws
Tue May 9 06:00:27 CDT 2006


it works but only on the third of forth clicks, do you have any idea as to 
why that might be?



here is the js

<p>
          <a href="#" onclick="jsfncShowHide('<%=strCalenderDOMID%>')">Show 
extended description for <%=rsCalendarRead("EventTitle")%></a>
         </p>


the div being hidden is initially being shown as "display: none;"



function jsfncShowHide(exID)
 {

  var show=document.getElementById(exID)
  if(show.style.display=="none")
   {
  show.style.display="block";
  }
   else
    {
     show.style.display="none";
     }

 }

Thanks

Abyss



----- Original Message ----- 
From: "Andrew Gibson" <andrew at shuttle.net.nz>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Tuesday, May 09, 2006 6:57 PM
Subject: Re: [Javascript] Show and hide multiple div tags


> something like this:
>
> where exID is the id of your "ExtendedDescription"
>
> function showHide(exID)
> {
>  var show=document.getElementById(exID)
>
> if(show.style.display=="none")
>    show.style.display="";
>  else
>   show.style.display="none"
>
> }
>
>
>
> ==========================================
> Perhaps - would it be best to put in an ID for each news item?
>
> eg
>
>
> <div class="News">
>    <div id="NewsItem">
>        <h2>News title 1</h2>
>        <div class="BriefDescription"></div>
>        <div class="ShowExtendedDescription"><a href="#"
> onclick="jsfncShowHideExtendedDescription('NI1234')">Show Extended
> Description for this event</a></div>
>        <div id="NI1234" class="ExtendedDescription"></div>
>    </div>
>
> if so how would I pass the news item to the function? like i have in this
> example? as a string?
>
> and how would i tell the browser to change the class for that particular
> div?
>
> Thanks
>
> Regards
> Abyss
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 





More information about the Javascript mailing list