Reputation: 3519
Here is how I create the textbox:
box = document.createElement("input");
Here is how I change the text:
box.setAttribute('value',myString);
However, each text-box becomes permanently unresponsive to the above code does after I edit it (in firefox, even clicking on it causes this).
Also, I would like to prevent the user form editing the value sometimes:
box.setAttribute('readonly','true');
But this also causes the boxes to lock permanently from the program trying to edit them; box.setAttribute('readonly','false') doesn't undo the lock.
Upvotes: 0
Views: 156
Reputation: 7590
You should use box.value = myString
and box.readOnly = false
. Node attributes are always strings and if you want to remove one you need to use element.removeAttribute('atribute_name')
.
Upvotes: 0
Reputation: 15036
To remove readonly property you must use box.removeAttribute('readonly');
Upvotes: 1