The ReadOnly attribute in JS is rather strange. Create an object directly and assign the readonly attribute to the object. You cannot use the following method like in HTML:
var x=document.createElement("input");
x.type="text";
x.value="ttttt ";
x.id="xy";
x.readonly="readonly";
The object created in this way is not read-only. The correct way to write it is:
var x=document.createElement( "input");
x.type="text";
x.value="ttttt";
x.id="xy";
x.readOnly=true;
You should pay attention to this when writing JS.