Get a reference to your input box however you like (eg document.getElementById('mytextbox')
) and set its readonly
property to true
:
myInputBox.readonly = true;
Alternatively you can simply add this property inline (no JavaScript needed):
<input type="text" value="from db" readonly="readonly" />