mendoz Posted January 24, 2007 Share Posted January 24, 2007 Hey Freaks.Well, the situation is like this:I have a form with an option box, which has "yes" and "no".I'd thought it'd be cool if when "yes" is selected another table row (tr) would appear and disappear when "no" is selected.Being a JS noob I need your help.Thanks,Dror Quote Link to comment Share on other sites More sharing options...
fenway Posted January 24, 2007 Share Posted January 24, 2007 Simply put an ID on that row, and toggle the display attribute accordingly. Quote Link to comment Share on other sites More sharing options...
mendoz Posted January 24, 2007 Author Share Posted January 24, 2007 Sorry but I'm not as good with javascript. An example could be nicethanks,Dror Quote Link to comment Share on other sites More sharing options...
lando Posted January 24, 2007 Share Posted January 24, 2007 The example below has radio buttons to show/hide row 1 of the table. The onClick event for each radio button sends the value of the radio button to the Javascript function, which uses that number to determine which row to show/hide.[code]<form> <input type="radio" name="something" value="row1" onClick="showRow(this.value)" /> Yes <input type="radio" name="something" value="row1" onClick="hideRow(this.value)" /> No</form><table> <tr id="row1" style="display:none;"> <td>Test 1</td> <td>Test 2</td> </tr> <tr id="row2" style="display:none;"> <td>Test 3</td> <td>Test 4</td> </tr></table>[/code][code]function showRow(num) { document.getElementById(num).style.display = 'block';}function hideRow(num) { document.getElementById(num).style.display = 'none';}[/code] Quote Link to comment Share on other sites More sharing options...
fenway Posted January 24, 2007 Share Posted January 24, 2007 That would be your example right there. Quote Link to comment Share on other sites More sharing options...
mendoz Posted January 24, 2007 Author Share Posted January 24, 2007 very cool!Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.