Chatbox

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 show/hide button on 28/3/2012, 5:36 pm

grimofdoom

avatar

Member
how do i make a button that will take a div and make it appear and dissapear(with the button staying in corner)

View user profile

2 Re: show/hide button on 28/3/2012, 6:04 pm

LGforum

avatar

Moderator
Thats javascript, not CSS.

There is actually a function in the forumotion system script for toggling elements like that.
The function is 'showhide()' and takes one parameter, which should be the element to toggle.

Example:
Code:

<div id="togggle-div" style="display:none"></div>

<div onclick="showhide(document.getElementById('toggle-div'))">Click</div>

View user profile

3 Re: show/hide button on 28/3/2012, 6:46 pm

grimofdoom

avatar

Member
This isnt for forumotion.this is for a regular site.

View user profile

4 Re: show/hide button on 29/3/2012, 8:41 am

Niko

avatar

Member
grimofdoom wrote:This isnt for forumotion.this is for a regular site.

That code works on Forumotion Like a Star @ heaven
Sure...

View user profile http://www.fmcodes.com

5 Re: show/hide button on 29/3/2012, 11:43 am

grimofdoom

avatar

Member
i find that last of which you said(niko) quite useless.

View user profile

6 Re: show/hide button on 29/3/2012, 12:02 pm

Niko

avatar

Member
grimofdoom wrote:i find that last of which you said(niko) quite useless.

Sorry, If it doesn't work try this one:
Code:
<a onclick ="javascript:ShowHide('HiddenDiv')" href="javascript:;" >Show/Hide</a>

<div class="mid" id="HiddenDiv" style="DISPLAY: none" >
This text was hidden
</div>

<script language="JavaScript">
function ShowHide(divId)
{
if(document.getElementById(divId).style.display == 'none')
{
document.getElementById(divId).style.display='block';
}
else
{
document.getElementById(divId).style.display = 'none';
}
}
</script>
Here you are a demo of this: http://codes.forumotion.pro/h7-hide-show

Bye bye Like a Star @ heaven Like a Star @ heaven

View user profile http://www.fmcodes.com

7 Re: show/hide button on 29/3/2012, 1:10 pm

grimofdoom

avatar

Member
It did not work. all it did was hide my div and when i click "show/hide' nothign happened.

View user profile

8 Re: show/hide button on 29/3/2012, 3:36 pm

Niko

avatar

Member
grimofdoom wrote:It did not work. all it did was hide my div and when i click "show/hide' nothign happened.

Have you seen it here?
http://codes.forumotion.pro/h7-hide-show

View user profile http://www.fmcodes.com

9 Re: show/hide button on 5/4/2012, 9:31 am

LGforum

avatar

Moderator
Here is a re-usable showhide function for you.

Code:

function showhide(elem,disp) {
  if(typeof elem == 'string') elem = document.getElementById(elem);
  if(elem.style.display == 'none') {
    elem.style.display == disp ? disp : 'block';
  }
  else {
    elem.style.display == 'none'
  }
}

It can be used on any elements over and over again. It also has some nice options. If you send a string in as the first parameter, it assumes it as an ID, and will toggle the element with that ID, alternatively you can send an Element Node into it and it will toggle that element. You can also specify the display if you wish, if you don't it will be set as 'block'.

Use it like this:

Code:

<div id="div_to_toggle">
this can be toggle
</div>
<div onclick="showhide('div_to_toggle');">Click to toggle above</div>

View user profile

10 Re: show/hide button on 6/4/2012, 8:26 pm

grimofdoom

avatar

Member
Thanks,i hope it works(on ie5 in las vegas computer lounge,html/java doesnt show well because their brocken ei5 browsers),ill try it when i get home.

View user profile

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

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