473,473 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to maintain table formatting after applying JS script?

75 New Member
Hello,

I am applying the following Javascript code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <script type="text/javascript">
  3. function showValue(){
  4. var selVal = document.getElementById('mySelect').options[document.getElementById('mySelect').selectedIndex].value;
  5. var tblObj = document.getElementById('myTable');
  6. var rowLen = tblObj.rows.length;
  7.  
  8. for(var i=0 ; i<rowLen ; i++)
  9. {
  10.  var idd = tblObj.rows[i].id;
  11.  if( parseFloat(idd) >= parseFloat(selVal) ){
  12.     tblObj.rows[i].style.display='block';
  13.  } else {
  14.     tblObj.rows[i].style.display='none';
  15.   }
  16.  }
  17. }
  18. </script>
  19.  
To this table
Expand|Select|Wrap|Line Numbers
  1. <table width="50%" border="0" id="myTable">
  2. <thead>
  3. <tr id="501">
  4.   <th>Rank</th>
  5.   <th>Player</th>
  6.   <th>Statistic</th>
  7. </tr>
  8. </thead> 
  9. <tr id="1.0000"> 
  10.   <td><div align="center">1</div></td> 
  11.   <td><div align="left" value="1.0000"><a href="frontend.php">Chacin</a></div></td> 
  12.   <td><div align="left">4.0000</div></td> 
  13. </tr> 
  14. <tr id="3.0000"> 
  15.   <td><div align="center">2</div></td> 
  16.   <td><div align="left" value="3.0000"><a href="frontend.php">Hill</a></div></td> 
  17.   <td><div align="left">1.3330</div></td> 
  18. </tr> 
  19. <tr id="4.0000"> 
  20.   <td><div align="center">3</div></td> 
  21.   <td><div align="left" value="4.0000"><a href="frontend.php">Ciriaco</a></div></td> 
  22.   <td><div align="left">1.2500</div></td> 
  23. </tr> 
  24. <tr id="1.0000"> 
  25.   <td><div align="center">4</div></td> 
  26.   <td><div align="left" value="1.0000"><a href="frontend.php">Kansen</a></div></td> 
  27.   <td><div align="left">1.0000</div></td> 
  28. </tr> 
  29. <tr id="1.0000"> 
  30.   <td><div align="center">5</div></td> 
  31.   <td><div align="left" value="1.0000"><a href="frontend.php">Meek</a></div></td> 
  32.   <td><div align="left">1.0000</div></td> 
  33. </tr> 
  34. </table>
  35.  
Whenever I apply the Javascript filter to the table, the table loses its formatting. How can I maintain the current table widths and alignments as I have them already after the javascript has been applied?

Any assistance would be very helpful! Thank you.
Oct 3 '10 #1
1 1429
RamananKalirajan
608 Contributor
Hi,
Hiding a table row is fine, just set
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(‘theRow’).style.display = ‘none’
When you’re trying to show it though, it can get confusing – for it to display properly, you’ve to set display=’table-row’ for Firefox and display=’block’ for IE.

The solution? Set display=” and the display property for the element gets set to its default (‘table-row’ for FF and ‘block’ for Explorer).

Thanks and Regards
Ramanan Kalirajan
Oct 4 '10 #2

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

Similar topics

1
by: Daniel Ruscoe | last post by:
Hi all, This is probably a simple one if you know what you're doing, but I could use some code to work from. I'd like to write a script that will take a single key value from rows in a MySQL...
1
by: LRW | last post by:
OK, this is probably an odd, but esy question. =) I taught myself PHP from a Julie Meloni book and newsgroup questions. So, I don't think I've really learned the proper way of organizing and...
20
by: Andy Fish | last post by:
Hi All, I have a nice easy table and/or CSS formatting problem for any gurus out there. I have a table with 4 columns - no "width" attribute on anything. Some rows have 4 cells in (call...
1
by: Peter | last post by:
Hi, I wonder there is a way to get the table creating SQL script from an exiting table in the sever explorer of VS 2003. Please advise Peter
2
by: Mike | last post by:
Greetings. I am having some difficulty with formatting a table on a web form and hope someone can help. Currently the table has a single column. Desired output format (X = text , X = number) ...
6
by: Christopher Benson-Manica | last post by:
I have some markup like the following: <form> <table> <script> <!-- Write the table markup //--> </script> </table> <form>
6
by: Kevin G. | last post by:
I'm not sure if this is possible, but if a page uses a CSS style sheet and you would still like to use good old <font> tags... is there a tag to tell the browser to ignore the CSS formatting just...
4
by: deko | last post by:
I've heard it's best not to have any formatting specified for Table fields (except perhaps Currency), and instead set the formatting in the Form or Report. But what about Yes/No fields? When I...
4
by: Martin Eyles | last post by:
Hi! I am trying to make several 1x3 tables on a webpage, where all three cells have black backgrounds and white text. However, I want the space around each of the cells, and the whole box to be...
3
by: gan | last post by:
Hi Friends, iam new hand in this fields,can you help me someone this is my problem code: <script language=JavaScript id=jscal1x> <table width="100%" border=1>
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.