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 Link to comment https://forums.phpfreaks.com/topic/35471-i-heard-there-were-some-freaks-around-here-form-thingy/ 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. Link to comment https://forums.phpfreaks.com/topic/35471-i-heard-there-were-some-freaks-around-here-form-thingy/#findComment-167973 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 Link to comment https://forums.phpfreaks.com/topic/35471-i-heard-there-were-some-freaks-around-here-form-thingy/#findComment-168053 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] Link to comment https://forums.phpfreaks.com/topic/35471-i-heard-there-were-some-freaks-around-here-form-thingy/#findComment-168075 Share on other sites More sharing options...
fenway Posted January 24, 2007 Share Posted January 24, 2007 That would be your example right there. Link to comment https://forums.phpfreaks.com/topic/35471-i-heard-there-were-some-freaks-around-here-form-thingy/#findComment-168096 Share on other sites More sharing options...
mendoz Posted January 24, 2007 Author Share Posted January 24, 2007 very cool!Thanks Link to comment https://forums.phpfreaks.com/topic/35471-i-heard-there-were-some-freaks-around-here-form-thingy/#findComment-168316 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.