By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

setAttribute readonly only works in mozilla

P: 77
hello all, i have this script below
Expand|Select|Wrap|Line Numbers
  1.             var td = document.createElement('td');
  2.             var theInput = document.createElement('input');
  3.             theInput.setAttribute('type', 'text');
  4.             theInput.setAttribute('name', 'codcnourut');
  5.             theInput.setAttribute('size', '3');        
  6.             theInput.setAttribute('value',form.codcnourut.value);
  7.             theInput.setAttribute('readonly','true');
  8.             td.appendChild(theInput);
  9.             row.appendChild(td);
i want to make theInput(object/field) become readonly with this script


but that works only in mozilla, doesn;t works in IE version 7..
and when i change the setAttribute readonly become like this one below

Expand|Select|Wrap|Line Numbers
  1. theInput.readonly=true;
still the same, that script works only in mozilla, not in IE

so any idea??
Sep 3 '08 #1
Share this Question
Share on Google+
2 Replies

P: 77
ok i have solved the problem

the script must like this one


see...not readonly, but readOnly (with uppercase of 'o')

kind regards..

Sep 3 '08 #2

Expert Mod 15k+
P: 16,027
The JavaScript readOnly property is with a capital O, but setAttribute should've worked with lower-case - see W3C link. IE doesn't follow suit.
Sep 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.