Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
2 buttons to 1 toggle button ?
Old 04-14-2009, 12:10 AM 2 buttons to 1 toggle button ?
Junior Talker

Posts: 2
Trades: 0
Good day to you all,
here is a question about making a show/hide toggle button instead of two separate button.

Here is my code :
Code:
function hide(li) {
       
  if (document.getElementById)
     document.poppedLayer = eval('document.getElementById(li)');
  else if (document.all)
     document.poppedLayer = eval('document.all[li]');
  else
     document.poppedLayer = eval('document.layers[li]');
  document.poppedLayer.style.display = "none";
}

function show(li) {
  if (document.getElementById)
     document.poppedLayer = eval('document.getElementById(li)');
  else if (document.all)
     document.poppedLayer = eval('document.all[li]');
  else
     document.poppedLayer = eval('document.layers[li]');
  document.poppedLayer.style.display = "block";
}
peuplarchie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-14-2009, 10:39 AM Re: 2 buttons to 1 toggle button ?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I'm not sure I understand the way your code is set up. (no need for an eval, that is for sure, and the legacy "else if (document.all)" statement is no longer required by today's standards).

What you are asking is very simple:
Code:
function toggle(li) {
  var element = document.getElementById(li);
  if(element.style.display == "none")
      element.style.display = "block";
  else
      element.style.display = "none";
}
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to 2 buttons to 1 toggle button ?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15825 seconds with 12 queries