Connecting Tech Pros Worldwide Help | Site Map

setAttribute readonly only works in mozilla

 
LinkBack Thread Tools Search this Thread
  #1  
Old September 3rd, 2008, 03:14 AM
Member
 
Join Date: Jul 2008
Location: Indonesia
Age: 23
Posts: 64
Default setAttribute readonly only works in mozilla

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);
  10.  
i want to make theInput(object/field) become readonly with this script

theInput.setAttribute('readonly','true');

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;
  2.  
still the same, that script works only in mozilla, not in IE

so any idea??
thanks

Last edited by gits; September 3rd, 2008 at 08:29 AM. Reason: added code tags
Reply
  #2  
Old September 3rd, 2008, 03:32 AM
Member
 
Join Date: Jul 2008
Location: Indonesia
Age: 23
Posts: 64
Default

ok i have solved the problem

the script must like this one

theInput.setAttribute('readOnly','true');

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

thanks
kind regards..

maminx
Reply
  #3  
Old September 3rd, 2008, 10:55 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,235
Default

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.
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.