This is a discussion on How to show a table when click a checkbox? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi buddies, I need to show a table when I click a checkbox. If I uncheck that box, table will ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi buddies, I need to show a table when I click a checkbox. If I uncheck that box, table will be hidden. Is there any sample javascript file?
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| Sponsored Links |
| |||
| Hi, You can do as ur wish....See my coding below, in check box tag, Code: onchange="check(this)" Code: function check(ctrl)
{
//get the state of the check box
if (ctrl.checked == true) {
//the box is checked, so show the table
document.all['moreInfo'].style.display = "inline";
} else {
//hide the table
document.all['moreInfo'].style.display = "none";
}
} Code: <table border="0" id="moreInfo" style="display:none"> <tr> <td>Something here</td> </tr> </table>
__________________ Krishnakumar.S Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily |
| |||
| Thnx krishna... It's working fine...Great help!
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| |||
| Wow! a great discussion. I have a question, how would I use it multiple times on 1 page calling a different table each time.. thanks in advance!
__________________ cheers Aman |
| |||
| Code: function check(tableId, ctrl)
{
document.getElementById(tableId).style.display = (ctrl.checked) ? "":"none";
}
...
<input type="checkbox" name="xxx" value="xxx" onclick="check('moreInfo', this)">
<input type="checkbox" name="yyy" value="yyy" onclick="check('whatever', this)"> |
| |||
| <html> <head> <script type="text/JavaScript"> <!-- function showlaptop(theTable) { if (document.getElementById(theTable).style.display == 'none') { document.getElementById(theTable).style.display = 'block'; } } //--> <!-- function hidelaptop(theTable) { if (document.getElementById(theTable).style.display == 'none') { document.getElementById(theTable).style.display = 'none'; } else { document.getElementById(theTable).style.display = 'none'; } } //--> </script> </head> <body> <table width="206" border="0" cellpadding="0" cellspacing="0" style="width: 30% border: 0;"> <tr width="100%"> <td> <input type="radio" name="pctype" value="desktop" onfocus="hidelaptop('laptop');return false;" checked /> <span class="linkswhite">No</span><input type="radio" name="pctype" value="laptop" onfocus="showlaptop('laptop');return true;"/> <span class="linkswhite">Yes </span></td> </tr> </table> <br> <div class="options"> <table border="0" cellpadding="0" cellspacing="0"> <tr id="laptop" style="display: none;"> <td class="linkswhite"><div align="left">CCJ<br> </div></td> <td> </td> </tr> <tr id="laptop" style="display: none;"> <td class="linkswhite">When was the CCJ Registered ? </td> <td><input name="textfield" type="text" class="textfield"></td> </tr> <tr id="laptop" style="display: none;"> <td class="linkswhite">How much was the CCJ for ? </td> <td><input name="textfield2" type="text" class="textfield"></td> </tr> <tr id="laptop" style="display: none;"> <td class="linkswhite">Is the CCJ Satisfied ? </td> <td><input name="textfield3" type="text" class="textfield"></td> </tr> </table> </div> </body> </html> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| count the time in seconds that a checkbox is really checked | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 02-13-2008 10:16 PM |
| What is the difference between DELETE TABLE and TRUNCATE TABLE commands in SQL Server | oxygen | Database Support | 6 | 11-23-2007 06:17 AM |
| checkbox validation | rajkumar | HTML, CSS and Javascript Coding Techniques | 5 | 11-16-2007 12:32 AM |
| I have multi checkbox in my form... | gk_cloud | PHP Programming | 2 | 10-22-2007 06:31 AM |
| I am having checkbox in datagrid and treeview, while click the button i need to check | kingmaker | C# Programming | 3 | 08-14-2007 09:39 AM |