473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How can i hide the columns whith JavaScript without bugs

http://www.fiendish.demon.co.uk/html...tablecols.html
This example is exactly what i need, but it's have a bug when using Opera (9.25 on my computer)
Does anybody now some other code like that?
Mar 4 '08 #1
5 1276
YAHOO ! Just need to replacing 'block' by ''
Now i search the way to do this without named element..
Mar 4 '08 #2
The problem is solved
Mar 4 '08 #3
acoder
16,027 Expert Mod 8TB
Can you share the final solution for the benefit of others? Thanks!
Mar 4 '08 #4
Can you share the final solution for the benefit of others? Thanks!
Shure.. the code is:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Show/Hide columns for Ciklum CRM</title>
  6. <script language="javascript">
  7.   function show_hide_column(btn,col_no) {
  8.     btn   = document.forms['tcol'].elements[btn];
  9.     stl = btn.checked ? '' : 'none';
  10.     var tbl  = document.getElementById('table_id');
  11.     var rows = tbl.getElementsByTagName('tr');
  12.  
  13.     for (var row=0; row<rows.length;row++) {
  14.       var cels = rows[row].getElementsByTagName('td');
  15.       cels[col_no-1].style.display=stl;
  16.     }
  17.   }
  18. </script>
  19. </head>
  20.  
  21. <body>
  22. <table id="table_id" width="100%" border=1>
  23. <tr>
  24. <td bgcolor="#666666" class="bold">column 1 text</td>
  25. <td bgcolor="#99FF00">column 2 text</td>
  26. <td bgcolor="#CC6633" class="italic">column 3 text</td>
  27. <td bgcolor="#FFFF33">column 4 text</td>
  28. </tr>
  29. <tr>
  30. <td bgcolor="#666666" class="bold">column 1 text</td>
  31. <td bgcolor="#99FF00">column 2 text</td>
  32. <td bgcolor="#CC6633" class="italic">column 3 text</td>
  33. <td bgcolor="#FFFF33">column 4 text</td>
  34. </tr>
  35. <tr>
  36. <td bgcolor="#666666" class="bold">column 1 text</td>
  37. <td bgcolor="#99FF00">column 2 text</td>
  38. <td bgcolor="#CC6633" class="italic">column 3 text</td>
  39. <td bgcolor="#FFFF33">column 4 text</td>
  40. </tr>
  41. </table>
  42. <p>&nbsp;</p>
  43. <p>&nbsp;</p>
  44. <form name="tcol" onsubmit="return false">
  45. Hide/Show columns
  46. <input type=checkbox name="col1" onclick="show_hide_column(this.name,1)" checked> 1
  47. <input type=checkbox name="col2" onclick="show_hide_column(this.name,2)" checked> 2
  48. <input type=checkbox name="col3" onclick="show_hide_column(this.name,3)" checked> 3
  49. <input type=checkbox name="col4" onclick="show_hide_column(this.name,4)" checked> 4
  50. </form>
  51. </body>
  52. </html>
  53.  
  54.  
Mar 11 '08 #5
acoder
16,027 Expert Mod 8TB
Thanks for posting.
Mar 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: adrien | last post by:
Hi, (also posted in netscape.public.mozilla.browser) i use netscape 7 and want to hide the scrollbars of the window when something happens. I tried this: window.scrollbars.visible=false...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
2
by: bela.patkai | last post by:
I have a css tabbed text menu (Home - Services - About - Contact) and would like to show appropriate text formatted in <divblocks on the webpage when clicking on the menu. Is it possible to do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.