I’m working on a web application. There are several screens that users can use to view information about various items, but depending on their access level, might not be able to edit the information. To avoid confusion, I wanted to pull the value from the disabled text boxes and replace them with regular paragraph text so that users wouldn’t get confused looking at something that looked like they could edit it.
It’s almost working, but not quite:
[CODE]function fieldToText() {
var inputs = document.getElementsByTagName(‘input’);
for (i=0; i<inputs.length; i++) {
if (inputs[i].disabled == true) {
var text = inputs[i].value;
var para = document.createElement(‘p’);
var paratext = document.createTextNode(text);
para.appendChild(paratext);
inputs[i].parentNode.replaceChild(inputs[i], para);
}
}
}
My code is throwing a DOM Exception: NOT_FOUND_ERR, saying the <input> can’t be found. I don’t understand. Can someone please help me?
Thank you!
Natalie
[COLOR=DarkRed]Edited to correct the comparison operator.