Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old September 3rd, 2008, 04:14 AM
Member
 
Join Date: Jul 2008
Location: Indonesia
Age: 22
Posts: 63
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 09:29 AM. Reason: added code tags
Reply
  #2  
Old September 3rd, 2008, 04:32 AM
Member
 
Join Date: Jul 2008
Location: Indonesia
Age: 22
Posts: 63
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, 11:55 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 12,964
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 205,248 network members.