onclick set a div from hidden to show

hi i have created a div with the style='visibility:hidden'

<div id='ge' style='visibility:hidden'>"

can anyone give me an example of setting the div style to show using onclick please?

thanks
ac_davis2002Asked:
Who is Participating?
 
hieloCommented:
<input type='button' onclick='var d= document.getElementById("ge"); d.style.visibility="visible" ' />
0
 
luckboxCommented:
You should change the style in a CSS form, it will be much easier to manipulate.

Some source I'm using:

#hiddenback {
      visibility:visible;
}

You should basically nest the style then "toggle" visibility using "document.getElementByID". I found a great article:

http://www.webmasterworld.com/javascript/3152822.htm'

Lots of ways to do this.



0
 
ac_davis2002Author Commented:
mmm cant get the link to work

I was hoping for a simple way of doing it really, I have created a button and wanted the onclick event to set the visibility to show? do I need to use javascript?

thanks
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
hieloCommented:
perhaps this is what you seek:
<input type='button' value='toggle view' onclick='var d=document.getElementById("ge"); d.style.display = d.style.display=="none" ? "block" :"none";'/>
<div id='ge' style='display:none;'>z</div>

Open in new window

0
 
luckboxCommented:
side note: you can use a link as well a href="#"
0
 
luckboxCommented:


Ok - heres something simple.  I created this for a site login page. When you click the textbox it sends the onFocus information "toggleMsg('msg-2')" to the java function, when onBlur it sends the same information to java.  It can be adapted to what you are trying to do.

Java:

function toggleMsg(idElement){
  element = document.getElementById(idElement);
  if(element.style.visibility!='hidden'){
    element.style.visibility='hidden';
  } else {
    element.style.visibility='visible';
  }
}


Text box onFocus/onBlur that changes the DIV:

<input name="textfield2" id="psw" onFocus="javascript:toggleMsg('msg-2')" onBlur="javascript:toggleMsg('msg-2')" type="password" maxlength="50"/>


DIV Iteself (thing we want to change):
<span class="style4 style10" id="msg-2" style="visibility:hidden;">Account locks after 3 failed attempts.</span>


0
 
BanthorCommented:
There is a limit to how meny Style Calls can executed in Mozilla and IE. it is better to keep all CSS in the style sheet.
I prefer the simple DOM method onClick="[ElementName].className='show andMove andbolder'.
className is case sensitive and the styles are applied left to right in the list seperated by spaces.
 
0
 
ac_davis2002Author Commented:
Thanks guys
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.