Solved

HTML text area uneditable

Posted on 2007-12-04
5
925 Views
Last Modified: 2013-12-13
ok so i need a text area in an html file that contains text that cannot be edited. kinda like what you see when you agree to terms and conditions then check a box that says i agree, then you proceed to login or signups.....
0
Comment
Question by:bcmeyer1983
5 Comments
 
LVL 20

Accepted Solution

by:
steelseth12 earned 125 total points
ID: 20406957
<textarea readonly name="mytext">text here</textarea>
0
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 125 total points
ID: 20406972
In fact, both the readonly and disabled attributes would work in your case, since it doesn't really matter if the terms text is sent with your form. Therefore, you can also do

<textarea name="mytext" disabled>text here</textarea>
0
 
LVL 2

Author Comment

by:bcmeyer1983
ID: 20406987
what does this to to it:
onFocus="this.blur()
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 20407004
That is Javascript code that will not let the user click into the field. It could be used to imitate readonly behavior (because readonly is subtly different from disabled) in extremely old browsers.

Nowadays, do not use something like that. It is Javascript, and many users have Javascript disabled. It can be done with the attributes steelseth and I have given you, so there is no need for it. (There may be other ways around the Javascript as well, but the attributes are pretty much foolproof).
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 20407044
try this
<script type="text/javascript">

function setRead(bool) {
   if(bool) {
      document.getElementById("ta").readOnly = true;
   }
   else {
      document.getElementById("ta").readOnly = false;
   }
}

</script>

<textarea id="ta"></textarea>
<input type="checkbox" onclick="setRead(this.checked)" />
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now