Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

show/hide a <TR> with a checkBox

Posted on 2002-07-04
7
Medium Priority
?
7,094 Views
Last Modified: 2012-05-04
How can I show or hide a table row depending on the status of a checkbox?

I have this - the table and form is placed in a layer <div></div>:

<table>
<tr>
<td>show/hide <input type="checkbox" name="toggle" value="1"><td>
<tr  style="display:none;" id="telTR">
<td class="dynaContent">Tel.<input type="text" name="tel" size="18">
</td>
</tr>
<table>

If I check the checkbox "toggle" the next row should be visible. If I uncheck it, the row should again disappear.

Must only work with IE 4+ NS 6

Thank you in advance
Joergen
0
Comment
Question by:jastroem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 600 total points
ID: 7130173

If the rows look like this: <TR id="therow" style="display:inline">
You do the check boxes this way: <input type="checkbox" onClick="toggle('therow')"

Then the function is:

<script language="JavaScript">
<!--
   function toggle(target)
   {
      obj=(document.all) ? document.all[target] : document.getElementById(target);
      obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
   }
//-->
</script>

I only have IE5.5 and MOZ1.0 installed so don't know i fit works for NS6.  MOZ1.0 screws up the rendering, so NS6 might have a problem with it.


Cd&
0
 

Author Comment

by:jastroem
ID: 7130268
Hi

Thank you very much for the rapid - and good - solution!

Here's my testing result:

PC/IE 6 => just fine
PC / NS 6.2 => fine, but additional empty rows are added if the toggle button is used several times

Mac/IE 5 => just fine
Mac/NS 6 => doesn't work

Kind regards
Joergen
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7130282
I was afraid NS 6 would be a problem.  MOZ1 was doing the same thing with sticking in the extra rows.  If I have some time next week I'll install 6.2 and see if I can find a way to clean it up. If I come up with something I'll post it here.

Cd&
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7130284
Anyway, glad we could get most of it to work.  Thanks for the A. :^)

Cd&
0
 
LVL 1

Expert Comment

by:tariqf
ID: 7740408
I have tried the above code, and it works well, but can anyone tell me how I modify it so that the table row is initially hidden, and then displayed (toggled) when the box is checked?
0
 

Expert Comment

by:richardys
ID: 8332849
change the <tr> tag to this:

<TR id="therow" style="display:none">
0
 
LVL 1

Expert Comment

by:longmatch
ID: 8739502
I would like to hide and show a row in my table based upon the selected value, for example, when users select 'other' in the dropdown list, this row shows, and hide otherwise.

Your help is highly appreciated

Longmatch
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question