<input type="checkbox" id="checkbox">
<input type="text" id="text">
<script>
document.getElementById( 'checkbox' ).addEventListener( 'click', function(){
var textInput = document.getElementById( 'text' );
textInput.readOnly = this.checked;
});
</script>