<input type="text" id="foo" value="foobar"><input type="button" onclick="document.getElementById('foo').readOnly=true" value="set readOnly">