How to make checkbox field ReadOnly in client script?

Dear all,
I have this situation. I trying to manage what field is or not readonly based on some checkbox fields.
Everything works just fine but checkbox field.
This is an example code (it is in the Client script->Table specific->Startup script).
//Begin code
// Check if the CheckBox PR is checked …
if($(“input[name=‘x_PR’]:checked”).val()){
$(‘#x_IL’).removeAttr(‘disabled’);
$(‘#x_F3’).removeAttr(‘disabled’);
$(‘#x_F4’).removeAttr(‘disabled’);
} else {
$(‘#x_IL’).attr(‘disabled’,‘disabled’);
$(‘#x_F3’).attr(‘disabled’,‘disabled’);
$(‘#x_F4’).attr(‘disabled’,‘disabled’);
}
// Check if the CheckBox PR is being checked…
$(“input[name=‘x_PR’]”).click(function() {
if (!this.checked) {
$(‘#x_IL’).attr(‘disabled’,‘disabled’);
$(‘#x_F3’).attr(‘disabled’,‘disabled’);
$(‘#x_F4’).attr(‘disabled’,‘disabled’);
} else {
$(‘#x_IL’).removeAttr(‘disabled’);
$(‘#x_F3’).removeAttr(‘disabled’);
$(‘#x_F4’).removeAttr(‘disabled’);
}
});
//End code

The fields PR and IL are CheckBox and the field F3 and F4 are varchar.
This code works for varchar but not for checkbox (F3 and F4 became disabled/enabled when I check PR but IL not)
Any ideea?
Thanks a lot.

Note that selecting by id, e.g. $(‘#x_field’) only select the first field. And if the field is a single checkbox, the id should be $(‘#x_field’). (In PHPMaker, single checkbox is just a special case of multiple checkboxes with n=1.)

Thanks for the answer.
Unfortunately it doesn’t work in my case.
I looked in the executed file and noticed that the id in all checkboxes has a different suffix after each generation of the project so I used the name instead of the id and it works.

You should select by name.