Results 1 to 7 of 7

Thread: **UNRESOLVED** How to hide & unhide tables from OnClick?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679

    **UNRESOLVED** How to hide & unhide tables from OnClick?

    I have an HTML page which at present is opening a different browser window for each link...so for example the HTML page has Link 1 that opens a page of graphs.....and Link 2 opens a page of data...etc

    I am looking to put these graphs & tables on the same page but hide them all, and only show the appropriate table once that specific link has been clicked...

    So is this possible, and if so, could someone help a newbie out with getting me started??

    Thank you all...
    Last edited by Salvatore; Aug 18th, 2003 at 01:28 PM.

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    Try something like this:

    Code:
    <script language="JavaScript1.2">
    function ShowIt(i_Name){
    	if(i_Name == "i_graph"){
    		document.all.i_graph.style.visibility = "visible"
    		document.all.i_data.style.visibility = "hidden"
    	} else {
    		document.all.i_graph.style.visibility = "hidden"
    		document.all.i_data.style.visibility = "visible"
    	}
    }
    </script>
    <a href="javascript: ShowIt('i_graph')">Show Graph</a> | <a href="javascript: ShowIt('i_data')">Show Data</a><br>
    <div id="i_graph" style="visibility: hidden; position:absolute">
    <table bgcolor="red"><td>Test 1</td></table>
    </div>
    
    <div id="i_data" style="visibility: hidden">
    <table bgcolor="blue"><td>Test 2</td></table>
    </div>
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679
    I really appreciate your response!

    I have a questions or two if you don't mind?

    With regards to this function you sent me, I will have several data pages and a few graph pages....do I label them within the function?

    For example you have -
    VB Code:
    1. if(i_Name == "i_graph"){
    2.         document.all.i_graph.style.visibility = "visible"
    3.         document.all.i_data.style.visibility = "hidden"
    4.     } else {
    5.         document.all.i_graph.style.visibility = "hidden"
    6.         document.all.i_data.style.visibility = "visible"
    Will I need to create individual If statements within this function for each page I wanted hidden?

    Also, I need the data or graph to show in the same position, much like a window on the page that will show the information...how do I write the position piece...

    I hope that I have explained myself...I thank you for your time and consideration!

  4. #4
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    This might work better for you then. I've made a few changes such as it now loops through each "DIV" tag for you so you don't have to mess with the "if" statements. I also changed the style attribute to "display" instead of "visibility" this should take care of your positioning issues. Note that this only works in IE as far as I know, maybe the newest netscape (not sure if it supports "div" tags).

    Let me know if you have any questions or need any more help.

    Code:
    <script language="JavaScript1.2">
    
    function ShowIt(i_Name){
    
    var a_Divs = document.all.tags("div")
    
    for(i=0;i<a_Divs.length;i++){
    	if(a_Divs[i].id != i_Name){
    		document.all[a_Divs[i].id].style.display = "none"
    	} else {
    		document.all[a_Divs[i].id].style.display = "block"
    	}
    }
    
    }
    </script>
    <a href="javascript: ShowIt('i_graph')">Show Graph</a> | <a href="javascript: ShowIt('i_data')">Show Data</a><br>
    <div id="i_graph" style="display: none">
    <table bgcolor="red"><td>Test 1</td></table>
    </div>
    
    <div id="i_data" style="display: none">
    <table bgcolor="blue"><td>Test 2</td></table>
    </div>
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679
    THIS IS GREAT!!!

    I really am learning alot....but I still need a little more prodding to the old brain!

    Ok, this is the code I am currently using...it uses a hide function for a menu style I have...My question is:
    Can I incorporate the function you created into this code...meaning can I use the DIV tags from my code to
    be used in your function...or am I way off
    VB Code:
    1. <Script Language="VBscript">
    2. <!--
    3. Option Explicit
    4. DIM menuID,menuObj,cellBk
    5. SUB ShowHide(menuID)
    6. menuObj = "Link" & menuID
    7. cellbk = "Head" & menuID
    8. // CHECK IF OPEN
    9. if document.all.item(menuObj).className = "LINKSON" then    'IF MENU OPEN THEN CLOSE
    10. document.all.item(menuObj).className = "LINKSOFF"
    11. document.all.item(cellBk).style.backgroundColor = "990000"   ' SET CELL BACKGROUND COLOUR BLUE          
    12. ELSE
    13. document.all.item(menuObj).className = "LINKSON"               ' OPEN MENU  
    14. document.all.item(cellBk).style.backgroundColor = "0066cc"  ' SET CELL BACKGROUND COLOUR RED          
    15. END IF
    16. END SUB
    17. -->
    18. </Script>
    19. </head>
    20. <body onload="WRITERPUBLISHER()">
    21. <p align="center"><img name="DIRECT BANKING-MAINQUALITY STATS TITLE" src="/intranet/icmimagelib.nsf/vwImages_Lkp/DIRECT+BANKING-MAINQUALITY+STATS+TITLE/$FILE/QltyStats.jpg?OpenElement" border="0"></img>
    22. </p>
    23. <center><font size=3><font color="cc0000"><b>Grade of Service Targets</b></font></center><P>
    24. <p align="center">
    25. <table>
    26. <td ID="head3" ALIGN="left" width="275" height="15" CLASS="HEADING" ONCLICK="ShowHide(3)"><img name="DIRECT BANKING-MAINANIMATED BALL" src="/intranet/icmimagelib.nsf/vwImages_Lkp/DIRECT+BANKING-MAINANIMATED+BALL/$FILE/Aniball1.gif?OpenElement" border="0"></img>Credit Card Auth 95/30</td>
    27. </tr>
    28. <tr>
    29. <td ALIGN="left" bgcolor="#FFFFCC">
    30. <!-- Menu 3 -->
    31. <div ID="Link3" CLASS="LINKSOFF">
    32. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4L4M?OpenDocument"><b>Totals</b></a><br>
    33. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q7PJF?OpenDocument"><b>Graphs</b></a><br>
    34. </div>
    35. </td>
    36. </tr>
    37.  
    38. <td ID="head4" ALIGN="left" width="275" height="15" CLASS="HEADING" ONCLICK="ShowHide(4)"><img name="DIRECT BANKING-MAINANIMATED BALL" src="/intranet/icmimagelib.nsf/vwImages_Lkp/DIRECT+BANKING-MAINANIMATED+BALL/$FILE/Aniball1.gif?OpenElement" border="0"></img>Premier 90/20</td>
    39. </tr>
    40. <tr>
    41. <td ALIGN="left" bgcolor="#FFFFCC">
    42. <!-- Menu 4 -->
    43. <div ID="Link4" CLASS="LINKSOFF">
    44. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4LK3?OpenDocument"><b>Totals</b></a><br>
    45. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q7Q23?OpenDocument"><b>Graphs</b></a><br>
    46. </div>
    47. </td>
    48. </tr>
    49. <p>
    50. <td ID="head2" ALIGN="left" width="275" height="15" CLASS="HEADING" ONCLICK="ShowHide(2)"><img name="DIRECT BANKING-MAINANIMATED BALL" src="/intranet/icmimagelib.nsf/vwImages_Lkp/DIRECT+BANKING-MAINANIMATED+BALL/$FILE/Aniball1.gif?OpenElement" border="0"></img>Priority 80/30</td>
    51. </tr>
    52. <tr>
    53. <td ALIGN="left" bgcolor="#FFFFCC">
    54. <!-- Menu 2 -->
    55. <div ID="Link2" CLASS="LINKSOFF">
    56. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4LRU?OpenDocument"><b>Combined Totals</b></a><br>
    57. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q7QE8?OpenDocument"><b>Combined Graphs</b></a><br>
    58. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4M8S?OpenDocument"><b>Sales Totals</b></a><br>
    59. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4MDQ?OpenDocument"><b>Lost & Stolen Totals</b></a><br>
    60. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4MKX?OpenDocument"><b>Branch Operations Totals</b></a><br>
    61. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4MPG?OpenDocument"><b>QCC Presidential Totals</b></a><br>
    62. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4N5H?OpenDocument"><b>Branch Lines Totals</b></a><br>
    63. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4N8B?OpenDocument"><b>Preferred Deposit/Cr.Card Totals</b></a><br>
    64. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4NAT?OpenDocument"><b>Preferred HELOC Totals</b></a><br>
    65. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4NF6?OpenDocument"><b>Preferred Sales Totals</b></a><br>
    66. </div>
    67. </td>
    68. </tr>
    69. <p>
    70. <td ID="head1" ALIGN="left" width="275" height="15" CLASS="HEADING" ONCLICK="ShowHide(1)"><img name="DIRECT BANKING-MAINANIMATED BALL" src="/intranet/icmimagelib.nsf/vwImages_Lkp/DIRECT+BANKING-MAINANIMATED+BALL/$FILE/Aniball1.gif?OpenElement" border="0"></img>Traditional 80/60</td>
    71. </tr>
    72. <tr>
    73. <td ALIGN="left" bgcolor="#FFFFCC">
    74. <!-- Menu 1 -->
    75. <div ID="Link1" CLASS="LINKSOFF">
    76. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4NPZ?OpenDocument"><b>Combined Totals</b></a><br>
    77. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q7QGQ?OpenDocument"><b>Combined Graphs</b></a><br>
    78. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4P5Z?OpenDocument"><b>General C/S Totals</b></a><br>
    79. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4P8M?OpenDocument"><b>HDPI Totals</b></a><br>
    80. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PBW?OpenDocument"><b>Business Lending Center Totals</b></a><br>
    81. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PED?OpenDocument"><b>HELOC/Select Credit Totals</b></a><br>
    82. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PHD?OpenDocument"><b>Credit Card Totals</b></a><br>
    83. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PKS?OpenDocument"><b>Ed Loans Totals</b></a><br>
    84. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PNX?OpenDocument"><b>Internet Banking Totals</b></a><br>
    85. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PRC?OpenDocument"><b>Card Activation Totals</b></a><br>
    86. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PTB?OpenDocument"><b>Hexagon Totals</b></a><br>
    87. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PV9?OpenDocument"><b>Cash Management Totals</b></a><br>
    88. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4PZ6?OpenDocument"><b>Spanish Market Totals</b></a><br>
    89. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4Q3C?OpenDocument"><b>Asian Totals</b></a><br>
    90. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4Q6R?OpenDocument"><b>Sales Totals</b></a><br>
    91. <a CLASS="nav" target="_blank" href="http://us-apps-06.us.hsbc/intranet/dept/icmdirbank.nsf/vwHTMLID/SCON5Q4Q9P?OpenDocument"><b>Emails Totals</b></a><br>
    92. </div>
    93. </td>
    94. </tr>
    95. </table>
    96. <br>
    97.  
    98. </body>
    I can not stress enough how much help you have all ready provided!!!!

    Thank you!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679
    Hello again!

    I tested out the function you sent me, and I am unable to open the simple Test tables you created within the DIV ID tags...it looks like it is opening another page instead making the table visible on the same page....

    Let me know if I am doing something wrong here....

    Thank you.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Location
    New York
    Posts
    679
    I really need to figure this out...so I am hoping that anyone out there can assist me!!!

    The following function will hide all DIV tags...this is my problem:
    VB Code:
    1. <script language="JavaScript1.2">
    2.  
    3. function ShowIt(i_Name){
    4.  
    5. var a_Divs = document.all.tags("div")
    6.  
    7. for(i=0;i<a_Divs.length;i++){
    8.     if(a_Divs[i].id != i_Name){
    9.         document.all[a_Divs[i].id].style.display = "none"
    10.     } else {
    11.         document.all[a_Divs[i].id].style.display = "block"
    12.     }
    13. }
    14.  
    15. }
    16. </script>
    I need only to hide specific tags....
    For example I have DIV ID tags that are associated with a menu script which will fold and unfold the menu like so:
    VB Code:
    1. <SCRIPT LANGUAGE="JavaScript">
    2. <!--
    3. function WRITERPUBLISHER()
    4. {
    5. self.status="Updated August 5, 2003"
    6. }
    7. //-->
    8. </SCRIPT>
    9. <style type="text/css">
    10. <!--
    11. #title{font-family:Arial;color:red;font-size:30px}
    12. #subtitle{font-family:Arial;color:black;font-size:22px}
    13. #normal{font-family:Arial;color:black;font-size:14px}
    14. #bold{font-family:Arial;color:black;font-size:14px;font-weight:bold}
    15. #credit{font-family:Arial;color:black;font-size:10px}
    16. -->
    17. </style>
    18.  
    19. <br>
    20.  
    21.  
    22. <style>
    23. <!--
    24. a.nav:link   { font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif; font-size: 10px; text-decoration: none }
    25. a.nav:visited { font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif; font-size: 10px; text-decoration: none }
    26. a.nav:active { font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif; font-size: 10px; text-decoration: none }
    27. a.nav:hover  { font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif; font-size: 10px; text-decoration: none; color: #FF0000 }
    28. .HEADING     { cursor: hand; font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif; font-size: 12px; color: #FFFFFF;
    29.                background-color: #0000FF; font-weight: none;
    30.                border: 1 solid #000000 }
    31. .LINKSOFF    { display: none; font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif; font-size: 12px; color: #000080 }
    32. .LINKSON     { display: inline; font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif; font-size: 12px; color: #000080 }
    33. .title {color: black; font-weight: bold; font-size: 24pt; font-family: Arial, helvetica, sans-serif ; text-decoration: none; pt: font-family: Arial, helvetica, sans-serif}
    34. -->
    35. </style>
    36.  
    37. <Script Language="VBscript">
    38. <!--
    39. Option Explicit
    40. DIM menuID,menuObj,cellBk
    41. SUB ShowHide(menuID)
    42. menuObj = "Link" & menuID
    43. cellbk = "Head" & menuID
    44. // CHECK IF OPEN
    45. if document.all.item(menuObj).className = "LINKSON" then    'IF MENU OPEN THEN CLOSE
    46. document.all.item(menuObj).className = "LINKSOFF"
    47. document.all.item(cellBk).style.backgroundColor = "990000"   ' SET CELL BACKGROUND COLOUR BLUE          
    48. ELSE
    49. document.all.item(menuObj).className = "LINKSON"               ' OPEN MENU  
    50. document.all.item(cellBk).style.backgroundColor = "0066cc"  ' SET CELL BACKGROUND COLOUR RED          
    51. END IF
    52. END SUB
    53. -->
    54. </Script>
    So can someone please show me how to change the first function so that only specific DIV tags are hidden???

    As it is now when I use the first function it will hide the other menu items and I can not get them back!!

    I really appreciate any suggestions!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width