radio button to display and hide div in javascript


Radio button to diaplay hide div in javascript

       radio button form         
        <form> 
                    <div> 
                        <input type="radio" S name="login" value="js_login_div" checked="checked"/> <p> Job Seeker </p> 
                        <input type="radio"  name="login" value="emp_login_div" /> <p> Employer </p> 
                    </div>
                 </form><div id="js_login_div">
   <form name=""> 
                    <div> 
                        <label> Email or Phone </label> 
                        <input type="text" value="" /> 
                        <input type="checkbox" value="" /> <span> keep me logged in </span> 
                    </div> 
                    <div> 
                        <label> Password </label> 
                        <input type="text" value="" /> 
                        <a href="#"> Forgot your Password? </a> 
                    </div> 
                    <input type="submit" value="Log In" /> 
                </form>
</div>

The div to display and hide

<div id="emp_login_div">
   <form name=""> 
                    <div> 
                        <label> Email or Phone </label> 
                        <input type="text" value="" /> 
                        <input type="checkbox" value="" /> <span> keep me logged in </span> 
                    </div> 
                    <div> 
                        <label> Password </label> 
                        <input type="text" value="" /> 
                        <a href="#"> Forgot your Password? </a> 
                    </div> 
                    <input type="submit" value="Log In" /> 
                </form>
</div>

script and style

 <style>
.descs {
 display:none;   
}
</style> 
<script>
$(document).ready(function() {
   $("input[name$=login]").change(function() {
        var test = $(this).val();
        $(".desc").hide();
        $("#" + test).show();
    });
    $("input[name$=login]:checked").change();
});
</script>
Advertisements
About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: , , , , , , , , , , , , , ,
Posted in javascript and jquery

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow php tutorial on WordPress.com
categories
Calendar
February 2014
M T W T F S S
« Jan   Mar »
 12
3456789
10111213141516
17181920212223
2425262728  
Follow me on Twitter
Blog Stats
  • 72,886 hits
%d bloggers like this: