skip to Main Content

enter image description here

$(document).ready(function() {
        $('.editbtn').on('click', function(){

            $('#editmodal').modal('show');
            $tr=$(this).closest('tr');
            var data= $tr.children("td").map(function(){
              return $(this).text();
            }).get();
            console.log(data);

            $('#update_id').val(data[0]);
            $('#finame').val(data[1]);
            $('#liname').val(data[2]);
            $('#Eimail').val(data[3]);
            $('#ContactNumber').val(data[4]);
            $('#Giender').val(data[5]);
            $('#Dob').val(data[6]);
            $('#addriess').val(data[7]);
            $('#Ciity').val(data[8]);
            $('#pinicode').val(data[9]);
            $('#stiate').val(data[10]);
            $('#countiry').val(data[11]);
            $('#HobbyiDrawing').each(function(){ this.checked = true; });
            $('#HobbyiDrawing').each(function(){ this.checked = false; });
           // $('#HobbyiDrawing').attr('checked', true);
            $('#HighiSchool').val(data[13]);
        });
});

i want to checkbox and radio button as checked in update modal form how to resolve it please guide me

4

Answers


  1. $('#HobbyiDrawing').attr("checked",true);
    

    You can do it like this.

    Login or Signup to reply.
  2. try checked attribute in both input tags as give down

    <input type="radio" name="color" value="red" checked>
    
    <input type="checkbox" checked>
    
    Login or Signup to reply.
  3. You can use this construction for check all checkbox via JQuery

    onclick="$('input[name*='selected']').prop('checked', this.checked);"
    

    For radio buttons you can use those methods – How to set radio button status with JavaScript

    Login or Signup to reply.
    • Set your dynamic value in values variable to checked checkbox or
      radio
    $('input[value='+values+'').attr('checked', true);
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search