Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Closed Thread
 
Thread Tools Display Modes
Old Sep 21st, 2007, 4:45 PM   #1
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 146
Rep Power: 10 paulchwd is on a distinguished road
.style.visibility = 'visible';

Hello This will not work:

     function help()
     {
           var xx;
           xx = document.getElementById('xx');
           xx.style.visibility = 'visible';
      }

but this will

     function help()
     {
           var xx;
           xx = document.getElementById('xx');
           xx.style.visibility = 'hidden';
      }

The label (xx) is set to visible=false in visual studio..could this by why
paulchwd is offline  
Old Nov 8th, 2007, 7:43 AM   #2
Farflungfish
Newbie
 
Join Date: Nov 2007
Posts: 6
Rep Power: 0 Farflungfish is on a distinguished road
Re: .style.visibility = 'visible';

javascript Syntax (Toggle Plain Text)
  1. function toggle(DivId) {
  2. if (document.getElementById(DivId).className == "visible") {
  3. document.getElementById(DivId).className = "hidden";
  4. } else {
  5. document.getElementById(DivId).className = "visible";
  6. }
  7. }

Created css styles with display.block: false / true; names visible/hidden.
works with everything not just divs

sorry if im completely off topic
Farflungfish is offline  
Old Nov 8th, 2007, 12:12 PM   #3
cscgal
Hobbyist Programmer
 
cscgal's Avatar
 
Join Date: Oct 2007
Location: New York
Posts: 183
Rep Power: 10 cscgal is on a distinguished road
Re: .style.visibility = 'visible';

There is no such thing as display:hidden. Your choices are display:block or display:none.
__________________
DaniWeb IT Discussion Community
Everything Information Technology related all in one convenient interactive online publication and community
cscgal is offline  
Old Nov 8th, 2007, 1:13 PM   #4
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,740
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
Re: .style.visibility = 'visible';

@dani: He isn't using the display attribute, he is using the visibility attribute of style which does contain hidden and visible.

@paulchwd: I am not sure what is wrong, but from the looks of it, it is exactly what I did below and it works for me. http://www.kylekonline.com/test/visible.html <= if you want to see it working.
html Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title>Test Javascript</title>
  4. <script type="text/javascript" language="javascript">
  5. function showFirst()
  6. {
  7. var xx;
  8. xx = document.getElementById('xx');
  9. xx.style.visibility = 'visible';
  10. }
  11.  
  12. function hideFirst()
  13. {
  14. var xx;
  15. xx = document.getElementById('xx');
  16. xx.style.visibility = 'hidden';
  17. }
  18.  
  19. function showSecond()
  20. {
  21. var yy;
  22. yy = document.getElementById('yy');
  23. yy.style.display = 'block';
  24. }
  25.  
  26. function hideSecond()
  27. {
  28. var yy;
  29. yy = document.getElementById('yy');
  30. yy.style.display = 'none';
  31. }
  32. </script>
  33. </head>
  34. <body>
  35. <a href="javascript:;" onClick="showFirst()">Show First Div</a><br />
  36. <a href="javascript:;" onClick="hideFirst()">Hide First Div</a><br />
  37. <div id="xx">This is the first div called xx</div>
  38.  
  39. <br /><br />
  40.  
  41. <a href="javascript:;" onClick="showSecond()">Show Second Div</a><br />
  42. <a href="javascript:;" onClick="hideSecond()">Hide Second Div</a><br />
  43. <div id="yy">This is the second div called yy</div>
  44. </body>
  45. </html>
__________________
BIG K aka Kyle
Programming Forums
Kydovik Web Development

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline  
Old Nov 8th, 2007, 4:28 PM   #5
Farflungfish
Newbie
 
Join Date: Nov 2007
Posts: 6
Rep Power: 0 Farflungfish is on a distinguished road
Re: .style.visibility = 'visible';

Quote:
Originally Posted by cscgal View Post
There is no such thing as display:hidden. Your choices are display:block or display:none.
sorry couldn't be bothered looking it up, i actually substituted block/none for true/false - the hidden/display is for the class names in the css.

though ill use hidden/visible for this css:
css Syntax (Toggle Plain Text)
  1. .visible {
  2. display: block;
  3. }
  4. .hidden {
  5. display: none;
  6. }

javascript Syntax (Toggle Plain Text)
  1. function toggle(DivId) {
  2. if (document.getElementById(DivId).className == "visible") {
  3. document.getElementById(DivId).className = "hidden";
  4. } else {
  5. document.getElementById(DivId).className = "visible";
  6. }
  7. }

html Syntax (Toggle Plain Text)
  1. <a href="#nothing" onclick="toggle('divid')"> Clicky clicky</a>
  2.  
  3. <div id='divid' class='hidden'>woot woot hide me show me</div>

Also using display:block/display:none means that IE won't substitute a hidden div with space, instead it will render nothing until told to.

Last edited by Farflungfish; Nov 8th, 2007 at 4:38 PM.
Farflungfish is offline  
Closed Thread

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rectangle in EAST is partially visible susam_pal Java 0 Sep 30th, 2005 12:44 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC