Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 3rd, 2008, 04:14 AM
Member
 
Join Date: Jul 2008
Location: Indonesia
Age: 22
Posts: 59
Default setAttribute readonly only works in mozilla

hello all, i have this script below
[CODE=javascript]
var td = document.createElement('td');
var theInput = document.createElement('input');
theInput.setAttribute('type', 'text');
theInput.setAttribute('name', 'codcnourut');
theInput.setAttribute('size', '3');
theInput.setAttribute('value',form.codcnourut.valu e);
theInput.setAttribute('readonly','true');
td.appendChild(theInput);
row.appendChild(td);
[/code]
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

[CODE=javascript]theInput.readonly=true;
[/code]
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: 59
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,593
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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles