Toggle Field Readonly

HTML

<table>
<tr>
  <td>
  <label >
    Lock
    <input type="checkbox" name='toggle'>
  </label>
  </td>
  <td>
    <input type="number" name="right" value="11.4" />
  </td>
</tr>
</table>

CSS

input:read-only { 
    background-color: gray;
}

JavaScript

$("input[name='toggle']").on("change", function(){
	if(this.checked){
  	$("input[name='right']").prop("readonly", true);
  }else{
  	$("input[name='right']").removeAttr("readonly");
  }
});