You must Sign In to post a response.
  • Category: JQuery

    Radio button inside html table not working

    Hi,
    In my application i have radio button inside an html table.
    i wrote the code for click event using jquery like this
    $('body').on('click', '.op1', function () {


    var id = $(this).attr("id");
    var td = $(this).closest('tr').children('td');
    var rk = td.eq(0).text();
    $('#ContentPlaceHolder1_txtstid').val(rk);
    $('#divstudent').show();

    });

    problem is when i click any radio button it is activating and click another radio button it is also activate and previous one not deacivating.
    how to solve this.
    here radio button is inside an html table
  • #757815
    Hi Baiju,

    Find the below code. it's working.
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>checked demo</title>
    <style>
    input, label {
    line-height: 1.5em;
    }
    </style>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>

    <form>
    <div>
    <input type="radio" name="fruit" value="orange" id="orange">
    <label for="orange">orange</label>
    </div>
    <div>
    <input type="radio" name="fruit" value="apple" id="apple">
    <label for="apple">apple</label>
    </div>
    <div>
    <input type="radio" name="fruit" value="banana" id="banana">
    <label for="banana">banana</label>
    </div>
    <div id="log"></div>
    </form>

    <script>
    $( "input" ).on( "click", function() {
    $( "#log" ).html( $( "input:checked" ).val() + " is checked!" );
    });
    </script>

    </body>
    </html>

    Mark the answer if it helped you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."


  • Sign In to post your comments