I am using a checkbox in my code, I want to add a readonly property to the textbox, but I saw that readonly property cannot be added to checkbox. The suggested alternative is to set disabled to true.
But the case is if i set disabled property to true. I cannot get the checkbox value server side. I want a solution that sets the checkbox readonly and can get value in server side.
How can I do this?
This is my view:
<input id="AddNewProductCategory" class="" type="checkbox" tabindex="1900" name="addnewproductcategory" value="1" checked="checked">
JavaScript:
$(document).ready(function(){
jq('#AddNewProductCategory').attr('checked',true);
});
In my server:
$check_box_val = $this->ci->input->post('addnewproductcategory');
I am using CodeIgniter and jQuery.
You could add a hidden field –
then set that when the checkbox gets clicked –