Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Tuesday, 12 May 2015

Introduction: 

In this article I will explain how to show or hide div when clicking the radio button with using jQuery in ASP.NET.


Following jQuery Script we will use to Show or Hide Div:

<script type="text/javascript">
    $(function () {
        $('input[name=rdbStatus]').change(function () {
            var selval = $('input[name=rdbStatus]:checked').val();
            if (selval == 'Show')
                $("#testdiv").fadeIn();
            else
                $('#testdiv').fadeOut();
        })
    });
</script>

Full Source for Sample Application:

For demo create your web application as given below and check the result.

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title> Show or Hide Div on radio button click or selection</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        $('input[name=rdbStatus]').change(function () {
            var selval = $('input[name=rdbStatus]:checked').val();
            if (selval == 'Show')
                $("#testdiv").fadeIn();
            else
                $('#testdiv').fadeOut();
        })
    });
</script>
</head>
<body>
<form id="form1">
<fieldset style="width:300px">
    <legend><strong> Show or Hide Div on radio button click</strong></legend>
<div>
<b>Select Radio Button :</b>
<input type="radio" name="rdbStatus" value="Show" checked="checked" />Show
<input type="radio" name="rdbStatus" value="Hide" />Hide
<br /><br />
<div id="testdiv" style="padding:20px; border:5px solid #fff; width:80%; font-weight:bold;background:#EB5E00;color:#fff;">
Show or Hide Div on radio button click or selection using jquery in asp.net.
</div>
</div></fieldset>
</form>
</body>

</html>

0 comments:

Post a Comment