Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / July 2006



Tip: Looking for answers? Try searching our database.

Setting a textarea to read only

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lovens Weche - 30 Jul 2006 18:44 GMT
I'm trying to set the "readonly" attribute of a "textarea" element this way:

---------------------------------

<script type="text/javascript">

***snip***

//-- create text area element --

var objTextArea;

objTextArea = document.createElement('textarea');

objTextArea.setAttribute('id', 'textArea' + this.InfoBoxID);

objTextArea.setAttribute('rows', this.TextAreaRows);

objTextArea.setAttribute('cols', this.TextAreaCols);

objTextArea.setAttribute('readonly', 'readonly');

document.getElementById('masterDiv').parentNode.appendChild(objTextArea);

document.getElementById('textArea' + this.InfoBoxID).style.position =
'absolute';

document.getElementById('textArea' + this.InfoBoxID).innerHTML =
textInTextArea;

//------------------------------

***snip***

</script>

</head>

<body onload="Onload();" bgcolor="#FFFF99">

<div id="masterDiv"></div>

</body>

---------------------------------

In this code, the textarea is never set to read only. I can always change
the content.

Also how can I had a node without the need to create the <div> masterDiv??

Thanks in advance!

=============================
Lovens Weche
Sirinik Team - "Games you can't live without"
www.sirinikteam.com
=============================
Martin Honnen - 30 Jul 2006 18:55 GMT
> I'm trying to set the "readonly" attribute of a "textarea" element this way:

> objTextArea = document.createElement('textarea');

> objTextArea.setAttribute('readonly', 'readonly');

Use the HTML DOM as follows
  objTextArea.readOnly = true;
that has much better cross browser support than setAttribute has in HTML
documents.

Signature

    Martin Honnen
    http://JavaScript.FAQTs.com/

Lovens Weche - 31 Jul 2006 18:42 GMT
ok it works now... Thanks Martin!

Lovens

>> I'm trying to set the "readonly" attribute of a "textarea" element this
>> way:
[quoted text clipped - 7 lines]
> that has much better cross browser support than setAttribute has in HTML
> documents.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.