Example : A program to show/hide the div and fieldset codes in JS on clicking the radio button.
<!DOCTYPE html>
<html>
    <head>
        <title>JSP Page</title>
        <h1>Two Fieldset Show/Hide One by One</h1>
        
        <script>

            function hide()
            {
                if(document.form1.f2.checked===true)
                {
                    fieldset2.style.display="none";
                    fieldset3.style.display="block";                
                }
            }

            function unhide()
            {
                if(document.form1.f3.checked===true)
                {                    
                   fieldset3.style.display="none";                   
                   fieldset2.style.display="block";
                   //fieldset2.style.display="inline";
                }
            }            
            
        </script>
    </head>

    <body>
        <form name="form1">
            <table>
                <tr>
                    <td>
                        <input type="radio" onclick="hide();" name="fset" id="f2" >Show fieldset1
                        <input type="radio" onclick="unhide();" name="fset" id="f3" >Show fieldset2    
                    </td>
                </tr>
            </table>
            
               <fieldset  name="fieldset" id="fieldset2"></fieldset>
                <br>
            
               <fieldset  name="fieldset1" id="fieldset3"></fieldset>
        </form>
    </body>
</html>

Link for other supporting fieldset codes in JS

Loading


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.