Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>C S</title>
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
	<script type="text/javascript">                
        $(document).ready(function(){
        $('#btnGetValue').click(function() {
        var selValue = $('input[name=rbnNumber]:checked').val(); 
        $('p').html('<br/>Selected Radio Button Value is : ' + selValue + '');
    });
});              
    </script>
</head>
<body>
	<input type="radio" name="rbnNumber" value="1" /> Number 1<br/>
        <input type="radio" name="rbnNumber" value="2" /> Number 2 <br/>
        <input type="radio" name="rbnNumber" value="4" /> Number 4
        <br/><br/>
        <input type="button" id="btnGetValue" Value="Get Value" />
</body>
</html>


What I have tried:

changed radio button attributes
Posted
Updated 27-Dec-17 5:42am

1 solution

You have asked this code:
$('p').html('<br/>Selected Radio Button Value is : ' + selValue + '');
to display the selected value of the radio button inside any
<p>
tag. But you have not provided any
<p></p>
for it to display, add it to your HTML. BTW, you are using HTML5, there is no need to have
/
in ending any HTML tags, for example, instead of
<br />
, just
<br>
will do.
 
Share this answer
 
Comments
Karthik_Mahalingam 27-Dec-17 23:30pm    
5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900