onclick radio button show hide div

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Untitled Document</title>
        <script type="text/javascript">
            function show(str){
                document.getElementById('sh2').style.display = 'none';
                document.getElementById('sh1').style.display = 'block';
            }
            function show2(sign){
                document.getElementById('sh2').style.display = 'block';
                document.getElementById('sh1').style.display = 'none';
            }
        </script>
    </head>

    <body>
        <p>
            <input type="radio" name="r1" id="e1" onchange="show2()"/> I Am New User   
            <input type="radio" checked="checked" name="r1" onchange="show(this.value)"/> Existing Member
        </p>
        <div id="sh1">Hello There !!</div>
        <p> </p>
        <div id="sh2" style="display:none;">Hey Watz up !!</div>
    </body>
</html>

3.8
5
Alek 95 points

                                    &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
    &lt;head&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
        &lt;title&gt;Untitled Document&lt;/title&gt;
        &lt;script type=&quot;text/javascript&quot;&gt;
            function show(str){
                document.getElementById('sh2').style.display = 'none';
                document.getElementById('sh1').style.display = 'block';
            }
            function show2(sign){
                document.getElementById('sh2').style.display = 'block';
                document.getElementById('sh1').style.display = 'none';
            }
        &lt;/script&gt;
    &lt;/head&gt;

    &lt;body&gt;
        &lt;p&gt;
            &lt;input type=&quot;radio&quot; name=&quot;r1&quot; id=&quot;e1&quot; onchange=&quot;show2()&quot;/&gt;&nbsp;I Am New User&nbsp;&nbsp;&nbsp;
            &lt;input type=&quot;radio&quot; checked=&quot;checked&quot; name=&quot;r1&quot; onchange=&quot;show(this.value)&quot;/&gt;&nbsp;Existing Member
        &lt;/p&gt;
        &lt;div id=&quot;sh1&quot;&gt;Hello There !!&lt;/div&gt;
        &lt;p&gt;&nbsp;&lt;/p&gt;
        &lt;div id=&quot;sh2&quot; style=&quot;display:none;&quot;&gt;Hey Watz up !!&lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;

3.8 (5 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source