raman Posted April 20, 2010 Share Posted April 20, 2010 I have two radio buttons. each has its own relevant content which i want to display when one of the radio buttons is selected. I am using a simple javascript, however I don't see any effect, all the content remains displayed irrespective of the selection of the radio buttons. I have checked that other javascripts are working fine on the browser implying javascript is enabled. <html> <head> <script language=javascript> function formshowhide(id) { if(id == "quote") { document.getElementById('quotef').style.display = "block"; document.getElementById('otherf').style.display = "none"; } else { document.getElementById('quotef').style.display = "none"; document.getElementById('otherf').style.display = "block"; } } </script> </head> <body><table> <tr><td>Choose the prediction method:<label><input type="radio" name ="algo" value="SVM" checked="checked" onClick="formshowhide('quote')">SVM</label><label><input type="radio" name ="algo" value="ANN" onClick="formshowhide('other')">ANN</label> </td></tr> <div id="quotef"> <tr><td>Threshold <select name="thresh"> <option value='1.0'>1.0</option> <option value='0.9'>0.9</option> <option value='0.8'>0.8</option> </select> </td></tr></div> <div id="otherf" style="display:none;"> <tr> <td> Thresholdscore <select name="anresh"> <option value='1.0'>1.0</option> <option value='0.9'>0.9</option> <option value='0.8'>0.8</option> </select> </td></tr> <tr><td valign='top'> <b><br>etwork based on:</b></td> <td width=50% valign=''> <input type= "checkbox" value="1" name="dpcnet" checked disabled>Composition </td> </tr> <tr><td><hr SIZE="3" width=100%></td><td><hr SIZE="3" width=100%></td><td><hr SIZE="3" width=100%></td></tr> </div> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/199100-hideshow-divs-radio-buttons/ Share on other sites More sharing options...
raman Posted April 20, 2010 Author Share Posted April 20, 2010 i found that it is not possible to use tr tags with div tag. that's why my code is not working. Link to comment https://forums.phpfreaks.com/topic/199100-hideshow-divs-radio-buttons/#findComment-1045048 Share on other sites More sharing options...
F1Fan Posted April 20, 2010 Share Posted April 20, 2010 You are correct. What you actually wanted was to use the <tbody> tag. Wrap that around your table rows (<tr>) and you'll get what you're looking for, but don't use display 'block' for a tbody. Instead, use 'table-row-group,' and you can still use 'none.' Here's a good reference: http://www.w3schools.com/css/pr_class_display.asp Link to comment https://forums.phpfreaks.com/topic/199100-hideshow-divs-radio-buttons/#findComment-1045182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.