473,387 Members | 1,486 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,387 software developers and data experts.

how to hide unchecked row in table

9
how can we hide unchecked row in table

i hv a table with about 30 rows which have a checkbox and a bit of text each. What i am attempting to get a approach to do is to have 2 buttons at the bottom of the page - HIDE & SHOW. When the HIDE button is clicked i wana to hide all of the table rows which have UNCHECKED textboxes. When the SHOW button is clicked i wish to restore the visibility of all of the rows. i wana to do this in JavaScript (which is what i am getting problem with) - i have been capable to get bits of it to work at number of times but i am executing out of time and I actually i wana help. Any idea somebody has would be more than appreciated!

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=iso-8859-1" /> 
  5. <title>View records in MySQL</title> 
  6.  
  7. </head> 
  8.  
  9. <body> 
  10.  
  11. <?php 
  12. //connect to the database 
  13. $connect = mysql_connect("localhost","root",""); 
  14. mysql_select_db("login",$connect); //select the table
  15. $query = mysql_query( "SELECT * FROM employee ")or die(mysql_error());
  16. $show=$_POST['show'];
  17.  
  18.  
  19.  
  20.  
  21. $timezone = "Asia/Calcutta";
  22. if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
  23.  
  24.  
  25.     echo"<center><h2>";
  26.           echo "Cover id generate at :".date('d-m-Y g:i a');
  27.  
  28.           echo "</h2></center>";
  29.           // generate cover id using random number
  30.     $rand= rand();
  31.     echo"<center><h2>";
  32.           echo "Cover Id :".$rand;
  33.           echo "</h2></center>";
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. echo'
  42. <form action="'.$_SERVER['PHP_SELF'].'" method="post">
  43. <table width="100%" cellpadding="4" border="1">
  44. <tr>
  45. <td> id  </td>
  46. <td> reg_no  </td>
  47. <td> reg_time  </td>
  48. <td>name   </td>
  49. <td> email_id  </td>
  50. <td> valid_from  </td>
  51. <td> valid_to  </td>
  52. <td> pan_no  </td>
  53. <td>  policy </td>
  54. <td> org_name  </td>
  55. <td> reseller_id  </td>
  56. <td> reseller_name </td>
  57. <td>mark</td>
  58. </tr>';
  59.  
  60. while($row = mysql_fetch_assoc($query))
  61. {
  62.     echo'
  63. <tr>
  64. <td>'.$row['id'].'</td>
  65. <td>'.$row['reg_no'].'</td>
  66. <td>' .$row['reg_time'].'</td>
  67. <td>'.$row['name'].'</td>
  68. <td>'.$row['email_id'].'</td>
  69. <td>'.$row['valid_from'].'</td>
  70. <td>' .$row['valid_to'] .'</td>
  71. <td>'.$row['pan_no'].'</td>
  72. <td>' .$row['policy'].'</td>
  73. <td> '.$row['org_name'].'</td>
  74. <td>'.$row['reseller_id'].'</td>
  75. <td>' .$row['reseller_name'].'</td>
  76. <td><input type="checkbox" name="id[]" value="'.$row['id'].'"></td>
  77.  
  78. </tr>';    
  79. }
  80. mysql_free_result($query);
  81. echo '
  82. </table>
  83. <br>
  84. <div align="center">
  85.  
  86. <input type="submit" name="show"  value="show"  >
  87. <input type="reset" name="cancel"  value="Cancel mark">
  88. </div>
  89. </form>';
  90.  
  91. ?> 
  92.  
  93.  
  94. </body> 
  95. </html> 
  96.  
May 2 '13 #1
2 3739
Rabbit
12,516 Expert Mod 8TB
I don't see any javascript. It would help to see your javascript along with any error messages you're getting. It would also help to see the HTML source from the client side. We don't need the PHP stuff getting in the way.
May 2 '13 #2
Sherin
77 64KB
Try This Code

Expand|Select|Wrap|Line Numbers
  1. $("button").click(function(){
  2.     $("table tr").has(".check-box:not(:checked)").hide();
  3. });
  4. table, tr, td {
  5.     border: 1px solid black;
  6. }
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  8. <table>
  9.     <tr>
  10.         <th>Name</th>
  11.         <th>InUse</th>
  12.     </tr>
  13.     <tr>
  14.         <td>foo 1</td>
  15.         <td>
  16.             <input class="check-box" type="checkbox" checked disabled  />
  17.         </td>
  18.     </tr>
  19.     <tr>
  20.         <td>foo 2</td>                  
  21.         <td>
  22.             <input class="check-box" type="checkbox" disabled  />
  23.         </td>
  24.     </tr>
  25.     <tr>
  26.         <td>foo 3</td>                  
  27.         <td>
  28.             <input class="check-box" type="checkbox" checked disabled  />
  29.         </td>
  30.     </tr>
  31.     <tr>
  32.         <td>foo 4</td>                  
  33.         <td>
  34.             <input class="check-box" type="checkbox" disabled  />
  35.         </td>
  36.     </tr>
  37. </table>
  38. <button>Only checked</button>
Jan 11 '21 #3

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

Similar topics

1
by: Steve Bishop | last post by:
I would like to hide a table based on a fields value that is outside the table. Does anyone have an example of this? Help appreciated. Steve *** Sent via Developersdex...
7
by: Mad Scientist Jr | last post by:
Through messing around I got IE6 (win xp) to show/hide a table row. I gave my <TR> an ID of "trRow" and trRow.style.display='none'; hides it trRow.style.display='block'; displays it (will any...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
3
by: evanburen | last post by:
I'm using this to hide rows in a table created from ASP. This works well but I would like to also be able to 'Show' the records again that there hidden by removeEvents( ). Thanks. function...
6
by: Ian Collins | last post by:
I'm having a spot of bother hiding table columns in IE. With FF, setting the column cell's style.display to none (or changing the cell's class name to style that has display: none) completely...
6
by: michael941 | last post by:
Hi, I have 2 tables in an html page. I have div them separately and id them as id1 and id2. I have a link there. What I need is click the link to hide one table and show the other and verse when...
0
by: mswhiteside | last post by:
Hello Everybody, Im Trying to hide my tables so that they can't be imported/linked from another database. i've searched, and searched, and i have a question that i haven't found already asked...
7
by: mswhiteside | last post by:
Hello Everybody, Im Trying to hide my tables so that they can't be imported/linked from another database. i've searched, and searched, and i have a question that i haven't found already asked...
1
WyvsEyeView
by: WyvsEyeView | last post by:
I have a report on which each record could potentially display three checkboxes...call them chk1, chk2, chk3. To minimize clutter on the page, I only want to display the labels of the checkboxes that...
2
jbt007
by: jbt007 | last post by:
All, Access 2003 - WinXP I thought this would be a no brainer, but it seems to be a perplexing problem. I have a simple table I use for importing several text reports, use VBA to run through...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.