It is currently Sun Jan 21, 2018 8:32 pm


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [HTML & Javascript] Show Hide Function
PostPosted: Tue May 16, 2006 6:17 am 
I have no life!
I have no life!

Joined: Sun Feb 13, 2005 6:12 pm
Posts: 1504
Location: My Office
Well, I thought I would contribute to the Open Source World somemore today. I like contributing to the OS everyday actually. :D But, I am sure some of you know this function and others maynot. But here I will show you a easy to use script that you can modify to suit your needs to use the Show Hide JS Function.

Here is the code:
Code:
<script language="javascript" type="text/javascript">
<!--
var PreloadFlag = false;
var expDays = 90;
var exp = new Date();
var tmp = '';
var tmp_counter = 0;
var tmp_open = 0;

exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function SetCookie(name, value)
{
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape(value) +
      ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
      ((path == null) ? "" : ("; path=" + path)) +
      ((domain == null) ? "" : ("; domain=" + domain)) +
      ((secure == true) ? "; secure" : "");
}

function getCookieVal(offset)
{
   var endstr = document.cookie.indexOf(";",offset);
   if (endstr == -1)
   {
      endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name)
{
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)
   {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal(j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0)
         break;
   }
   return null;
}

function ShowHide(id1, id2, id3)
{
   var res = expMenu(id1);
   if (id2 != '') expMenu(id2);
   if (id3 != '') SetCookie(id3, res, exp);
}
   
function expMenu(id)
{
   var itm = null;
   if (document.getElementById)
   {
      itm = document.getElementById(id);
   }
   else if (document.all)
   {
      itm = document.all[id];
   }
   else if (document.layers)
   {
      itm = document.layers[id];
   }
   if (!itm)
   {
      // do nothing
   }
   else if (itm.style)
   {
      if (itm.style.display == "none")
      {
         itm.style.display = "";
         return 1;
      }
      else
      {
         itm.style.display = "none";
         return 2;
      }
   }
   else
   {
      itm.visibility = "show";
      return 1;
   }
}
//-->
</script>

<a href="javascript:ShowHide('attach_display','attach_hide','attach_cookie');">Testing Attachment Header</a>
<div id="attach_display" style="display: ''; position: relative;">
   <table width="50%">
      <tr>
         <th>Testing</th>
         <td>asdfsadf;a'sldkf'as;ldkf'a;sldkf'a;sldkf <br />asdf;lkas;dlfks'd;lfka's;ldfk</td>
      </tr>
   </table>
</div>

<div id="attach_hide" style="display: none; position: relative;">
   <table width="50%">
      <tr>
         <td>Testing Hide!</td>
      </tr>
   </table>
</div>

<script language="javascript" type="text/javascript">
tmp = 'attach_cookie';
if(GetCookie(tmp) == '2')
{
   ShowHide('attach_display','attach_hide','attach_cookie');
}
</script>


If you have any questions or concerns, please contact me or ask here! :D

_________________
Best Regards:
Aaron McGowan (aka: CyberGeek, =cipher=)

CyberGeek's Software Solutions
-- WWW: http://www.cybergeeksoftware.com
-- Tech Line: 1-519-860-4557
-- Email: cybergeek@cybergeeksoftware.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 3:54 pm 
Moderator
Moderator

Joined: Thu Dec 15, 2005 2:59 pm
Posts: 681
Location: England
What does it do?..

I know it shows and hides, but shows and hides what?

_________________
Mountain biking forum ;)
Ponds and fishkeeping :D


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 6:12 pm 
Experienced
Experienced

Joined: Fri Apr 28, 2006 9:49 pm
Posts: 50
Location: Texas
That cookie function you've got added in remebers whether or not it's closed, right? Like the one on GraphicStyles, right?

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 10:02 pm 
I have no life!
I have no life!

Joined: Sun Feb 13, 2005 6:12 pm
Posts: 1504
Location: My Office
Hehehe. You crack me up.

Answer: Yes it does :D

_________________
Best Regards:
Aaron McGowan (aka: CyberGeek, =cipher=)

CyberGeek's Software Solutions
-- WWW: http://www.cybergeeksoftware.com
-- Tech Line: 1-519-860-4557
-- Email: cybergeek@cybergeeksoftware.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 20, 2006 1:39 am 
Nice script :)


Top
  
 
 Post subject:
PostPosted: Sat May 20, 2006 5:40 am 
I have no life!
I have no life!

Joined: Sun Feb 13, 2005 6:12 pm
Posts: 1504
Location: My Office
Thanks Rm249 :D

_________________
Best Regards:
Aaron McGowan (aka: CyberGeek, =cipher=)

CyberGeek's Software Solutions
-- WWW: http://www.cybergeeksoftware.com
-- Tech Line: 1-519-860-4557
-- Email: cybergeek@cybergeeksoftware.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ]  Moderators: fhmagic, KJ, Support Team, Moderators

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011