document.getElementById("text").readonly='readonly';
Javascript doesn't use on/off, it generally uses true/false. Some properties such as "checked" and "disabled" are literal switches, as above.
If you want to work on groups of inputs you generally use class names, apply the same class to those you want to affect.
You can do this in plain JavaScript, but you will have to loop through the values:
var fields = document.getElementsByClassName('something');
for(var x=0;x<fields.length;x++) {
fields[x].setAttribute('readonly','readonly');
}
Moving to use jQuery has many benefits since it can all be done in one compact line:
$('.something').attr('readonly','readonly');