Welcome Guest, Not a member yet? Register   Sign In
checkbox value for Edit not showing as checkbox checked
#3

(This post was last modified: 08-04-2022, 09:33 AM by SubrataJ.)

Code:
<td>
                        <a href="#" class="btn btn-info btn-sm btn-edit" data-id="<?= $row->product_id;?>" data-product_available="<?= $row->product_available;?>" data-name="<?= $row->product_name;?>" data-price="<?= $row->product_price;?>" data-category_id="<?= $row->product_category_id;?>" data-subcategory_id="<?= $row->subcategory_id;?>">Edit</a>
                        <a href="#" class="btn btn-danger btn-sm btn-delete" data-id="<?= $row->product_id;?>">Delete</a>
                    </td>

although it's a bad idea to load everything like this for edit while u can fetch data from the server if you have a git repo I would love to give it a try since it's hard to cope with all the above-given codes here.

else try this out instead of attr, use prop

PHP Code:
$('#myCheckbox').prop('checked'true); // Checks it
$('#myCheckbox').prop('checked'false); // Unchecks it 

since you haven't specified any value for the checkbox

there is no need for this code 


Code:
$('.checkboxitem').val(product_available);
// start: code added here...
                if($('#product_available').val() == 'Y') {
                    $('#product_available').attr('checked', true);
                }else{
                    $('#product_available').attr('checked', false);
                }


use this instead 


Code:
//$('.checkboxitem').val(product_available); there's no need to set value
// start: code added here...
                if(product_available == 'Y') {
                    $('#product_available').prop('checked', true);
                }else{
                    $('#product_available').prop('checked', false);
                }
Learning Codeigniter 
Reply


Messages In This Thread
RE: checkbox value for Edit not showing as checkbox checked - by SubrataJ - 08-04-2022, 09:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB