The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

How to show/hide who is online?

View previous topic View next topic Go down

Solved How to show/hide who is online?

Post by iamthestreets on January 17th 2012, 9:12 pm

How can I add a show/hide button for "who is online?" section?


Last edited by iamthestreets on January 17th 2012, 10:47 pm; edited 1 time in total

iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by iamthestreets on January 17th 2012, 9:51 pm

Rideem3 wrote:Do you want to automatically hide it, and then have a button to show it?

Or do you want to show it a add a button that will hide it?

Automatically hide it, and then have a button to show it.

iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by LGforum on January 17th 2012, 10:21 pm

This:

Code:

<script type="text/javascript">
  function showstats() {
  $(document).ready(function() {
  $('.hiddenstat').show('slow');
  });
  document.getElementById('showS').style.display = "none";
  document.getElementById('hideS').style.display = "inline-block";
  }
 
  function hidestats() {
  $(document).ready(function() {
  $('.hiddenstat').hide('slow');
  });
  document.getElementById('showS').style.display = "inline-block";
  document.getElementById('hideS').style.display = "none";
  }
</script>

Can be shortened to this:

Code:

<script type="text/javascript">
function togglestats() {
  var x=document.getElementById('showS').style.display = "none";
  if (x.style.display!='none') {
    $('.hiddenstat').show('slow');
    x.style.display = "none";
    document.getElementById('hideS').style.display = "inline-block";
 } else {
    $('.hiddenstat').hide('slow');
    x.style.display = "inline-block";
    document.getElementById('hideS').style.display = "none";
}
</script>

Which would mean changing this:
Code:

<input type="button" value="Show Statistics" onclick="showstats()" id="showS"/><input style="display: none;" type="button" value="Hide Statistics" onclick="hidestats()" id="hideS" /></span>
      <!-- END switch_viewonline_link -->

to this:
Code:

<input type="button" value="Show Statistics" onclick="togglestats()" id="showS"/><input style="display: none;" type="button" value="Hide Statistics" onclick="togglestats()" id="hideS" /></span>
      <!-- END switch_viewonline_link -->

less code = better Wink
A toggling function is better than having two seperate function. Also, you don't need to start a jQuery function within a Javascript function as this function does not require the DOM to be loaded. (well it does, but it will only execute on click ... so it doesn't)

LGforum
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by iamthestreets on January 17th 2012, 10:27 pm

This is what it shows:


This is what it shows when I click the button:


All it does is change the text of the button.

The second code LGForum gave me doesn't do anything and it takes away the who is online? text.


I like the first code better but its not working 100%, but i will use either one if it show the who is online? text


Last edited by iamthestreets on January 17th 2012, 10:29 pm; edited 1 time in total

iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by LGforum on January 17th 2012, 10:30 pm

@iamthestreets wrote:This is what it shows:

The second code LGForum gave me doesn't do anything and it takes away the who is online?

Lol woops. Thats because there was a slight silly error in it. It should have been this:

Code:

       
        <script type="text/javascript">
        function togglestats() {
          var x=document.getElementById('showS');
          if (x.style.display!='none') {
            $('.hiddenstat').show('slow');
            x.style.display = "none";
            document.getElementById('hideS').style.display = "inline-block";
        } else {
            $('.hiddenstat').hide('slow');
            x.style.display = "inline-block";
            document.getElementById('hideS').style.display = "none";
        }}
        </script>

EDIT: this code above now works perfectly.


Last edited by LGforum on January 17th 2012, 10:32 pm; edited 1 time in total

LGforum
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by iamthestreets on January 17th 2012, 10:32 pm

Rideem3 wrote:Actually, the reason why it's displaying the birthday is because it's displayed as a PHP variable. For some reason I can't give it the class I gave the others. Wink

That I don't mind showing, but when i click the button to show statistics it does nothing.
(if you could hide the birthday info that would be cool too)

iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by iamthestreets on January 17th 2012, 10:34 pm

@LGforum wrote:
@iamthestreets wrote:This is what it shows:

The second code LGForum gave me doesn't do anything and it takes away the who is online?

Lol woops. Thats because there was a slight silly error in it. It should have been this:

Code:

       
        <script type="text/javascript">
        function togglestats() {
          var x=document.getElementById('showS');
          if (x.style.display!='none') {
            $('.hiddenstat').show('slow');
            x.style.display = "none";
            document.getElementById('hideS').style.display = "inline-block";
        } else {
            $('.hiddenstat').hide('slow');
            x.style.display = "inline-block";
            document.getElementById('hideS').style.display = "none";
        }}
        </script>

EDIT: this code above now works perfectly.

Thanks it worked, but is there any way to put the "Who is Online?" text back?

This it what it shows as now:


Can it show like this:


And is there any way possible to remove the birthday info?

iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by LGforum on January 17th 2012, 10:39 pm

You can remove the birthday info by adding this in the CSS:
Code:

.hiddenstat+tr{display:none;}

To toggle it with the rest of the stuff add this to the script:
Code:

$( $('.hiddenstat')[1].nextSibling ).toggle();

underneath where it says:
function togglestat() {


Last edited by LGforum on January 17th 2012, 10:42 pm; edited 1 time in total

LGforum
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by iamthestreets on January 17th 2012, 10:41 pm

@iamthestreets wrote:
@LGforum wrote:
@iamthestreets wrote:This is what it shows:

The second code LGForum gave me doesn't do anything and it takes away the who is online?

Lol woops. Thats because there was a slight silly error in it. It should have been this:

Code:

       
        <script type="text/javascript">
        function togglestats() {
          var x=document.getElementById('showS');
          if (x.style.display!='none') {
            $('.hiddenstat').show('slow');
            x.style.display = "none";
            document.getElementById('hideS').style.display = "inline-block";
        } else {
            $('.hiddenstat').hide('slow');
            x.style.display = "inline-block";
            document.getElementById('hideS').style.display = "none";
        }}
        </script>

EDIT: this code above now works perfectly.

Thanks it worked, but is there any way to put the "Who is Online?" text back?

This it what it shows as now:


Can it show like this:


And is there any way possible to remove the birthday info?

I figured this out.

iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by iamthestreets on January 17th 2012, 10:43 pm

@LGforum wrote:You can remove the birthday info by adding this in the CSS:
Code:

.hiddenstat+tr{display:none;}

Perfect! Thanks! You guys are awesome and thanks for the quick responses.

iamthestreets
Forumember

Posts : 114
Reputation : 1
Language : English

http://www.mystreetlife.forumotion.com/

Back to top Go down

Solved Re: How to show/hide who is online?

Post by Nera. on January 17th 2012, 10:48 pm

Topic Solved & Locked

Nera.
Energetic

Female Posts : 7077
Reputation : 2013
Language : English
Location : -

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum