Example : A Java Script program to show/hide the fieldsets on clicking 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>

 4,361 total views,  1 views today


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.