mme Posted April 22, 2008 Share Posted April 22, 2008 Hi I am trying to make it when using grouped radio buttons the user either presses yes or no. When Yes is pressed it shows the content in div id "dn2" and when No is pressed it hides div id "dn2" and shows "dn" instead. But when the page is loaded neither div id "dn" or "dn2" are to be shown. <body> <script type="text/javascript"> if( document.getElementById ) { getElemById = function( id ) { return document.getElementById( id ); } } else if( document.all ) { getElemById = function( id ) { return document.all[ id ]; } } else if( document.layers ) { getElemById = function( id ) { return document.layers[ id ]; } } function showhide( el, id) { if ( el && el.style ) { getElemById( id ).style.display = (el.checked)? 'none' : ''; } } </script> <label> <input type="radio" name="q1" value="radio" id="q1_0" onclick="showhide(this, 'dn2');" /> Yes</label> <label> <input type="radio" name="q1" value="radio" id="q1_1" onclick="showhide(this, 'dn');" /> No</label> <br> <div id="dn" class="noshow">Text 1</div> <div id="dn2" class="noshow">Text 2</div> </body> Thanks Quote Link to comment Share on other sites More sharing options...
shankar23 Posted April 22, 2008 Share Posted April 22, 2008 Hi, you need to show any one of the value while page is load right? For eg:- If yes is selected in your radio button it shoulkd show like this correct?? Yes [clicked] No [Not clicked] Text 1. correct????????? thanks, Shang.. 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.