I teach HS computers and one of my kids has a web site with a textbox of
info that the user can scroll down and read. The problem is that users can
also enter text into it. Is there a way, or a better control, method, to
prevent user from entering text?
Thanks,
Jim
Darin McGrew - 22 Feb 2005 23:32 GMT
> I teach HS computers and one of my kids has a web site with a textbox of
> info that the user can scroll down and read. The problem is that users can
> also enter text into it. Is there a way, or a better control, method, to
> prevent user from entering text?
Assuming that the "textbox" is a TEXTAREA element, its whole purpose is to
accept text from the user. There is no way to make it stop accepting text
from the user.
If you (or your student) gets rid of the TEXTAREA and marks up the text
normally (paragraphs, headings, lists, etc.), then the browser will provide
appropriate scrolling mechanisms automatically, if scrolling is needed.
If you put the marked-up text in a DIV element, then you can use CSS to
specify the size and scrolling behavior of the DIV element. But such things
often prevent the user from scrolling through the content normally (e.g.,
with the arrow keys, or with the Page Up or Page Down keys), so it's better
to let the browser handle scrolling on its own.

Signature
Darin McGrew, mcgrew@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, darin@htmlhelp.com, http://www.HTMLHelp.com/
"There is no right way to do the wrong thing."
Alan J. Flavell - 22 Feb 2005 23:57 GMT
> I teach HS computers and one of my kids has a web site with a
> textbox of info that the user can scroll down and read.
If you're referring to a forms textarea, then that's precisely what it
was designed for.
> The problem is that users can also enter text into it.
No, that's not the problem. The /problem/ is that it's being misused
for something that it wasn't intended for.
> Is there a way, or a better control, method, to prevent user from
> entering text?
Probably, What, actually, are you (or they) trying to achieve?
The crystal ball is cloudy, and there's no extra charge for telling
usenet - a bit more clearly - what the real-world problem is (in
preference to telling them what the failed solution was, and leaving
them to try and guess what the actual problem was, I mean)
Maybe <object...> or even (shudder) <iframe...> was what was intended?
But, if that was the answer (given the current browser support etc.),
there could have been something wrong with the question. So let's at
least hear the question, and then we can move forwards from there, OK?
JimO - 23 Feb 2005 01:20 GMT
I actually didn't look at the code. After reading Darin's message, I looked
a few things up and got some working code using overflow-y and overflow
properties. It works in both IE and Mozilla. I'm not sure how well it'll
work when they stick it in there. I'm just getting a handle on this myself
as a later post will reveal. I know there's a way to lock out users using
textboxes in compilable languages. I didn't know if there was a direct way
to do that using javascript or some other technology. I guess the question
is what is the best way to allow a user to read text that scrolls and not
allow them to change the text inside? I think I answered my own question.
If there is a better way, or a programable way, I'd love to hear it. Here
is the code I used...
<style type="text/css" media="all">
<!--
p {
width: 200px;
background-color: lightgrey;
color: #A52442;
height: 500px;
font-size: 1.3em;
text-align: justify;
float: left;
padding: 15px;
overflow-y: scroll;
overflow: scroll;
}
div#clleft {
clear: left;
}
-->
</style>
Thanks,
Jim
> > I teach HS computers and one of my kids has a web site with a
> > textbox of info that the user can scroll down and read.
[quoted text clipped - 20 lines]
> there could have been something wrong with the question. So let's at
> least hear the question, and then we can move forwards from there, OK?
Tony Marston - 23 Feb 2005 06:21 GMT
Within the textarea tag set the "readonly" attribute.

Signature
Tony Marston
http://www.tonymarston.net
>I teach HS computers and one of my kids has a web site with a textbox of
> info that the user can scroll down and read. The problem is that users
[quoted text clipped - 4 lines]
> Thanks,
> Jim
JimO - 24 Feb 2005 03:37 GMT
That's a much better solution to give the kids. They liked the CSS today
but I doubt they really understood it. The readonly attr is much more
direct.
Thanks
> Within the textarea tag set the "readonly" attribute.
>
[quoted text clipped - 6 lines]
> > Thanks,
> > Jim
JimO - 24 Feb 2005 03:37 GMT
Thanks for everyone's input.
Jim
> I teach HS computers and one of my kids has a web site with a textbox of
> info that the user can scroll down and read. The problem is that users can
[quoted text clipped - 3 lines]
> Thanks,
> Jim