scrollable text boxes?

D

david

Just wondering how to make a scrollable text box that will expand to
fit the user defined screen settings. The only text box I found was

<textarea read only>
sf
asdf
adsf
asdf
as
dfa
sdf
</textarea>

Or something like that, needless to say it didn't work because it only
made a tiny box.
I have a lot of text that needs to go within this box, so I want the
user to be able to read it and scroll up when they get to the bottom.
Thanks
 
A

Adrienne

Just wondering how to make a scrollable text box that will expand to
fit the user defined screen settings. The only text box I found was

<textarea read only> sf asdf adsf asdf as dfa sdf </textarea>

Or something like that, needless to say it didn't work because it only
made a tiny box.
I have a lot of text that needs to go within this box, so I want the
user to be able to read it and scroll up when they get to the bottom.
Thanks

Is this textarea box for a form, or are you using it to present
information? Just curious.

Anyway, what you're looking for is the cols and rows attributes. For
example:
<textarea cols="50" rows="4" name="textarea" id="textarea" readonly>some
text</textarea> will give room for approximately 200 characters, and will
automatically scroll for more.

However, you can also do this with CSS (if it's not really part of a
form). Take a look at the overflow property: http://www.w3.org/TR/REC-
CSS2/visufx.html#propdef-overflow .
 
D

david

<textarea cols="50" rows="4" name="textarea" id="textarea" readonly>some
text</textarea>

Thanks but I am not using CSS at all, want to do it the old-fashioned
way.
 
R

Richard

david said:
Just wondering how to make a scrollable text box that will expand to
fit the user defined screen settings. The only text box I found was
<textarea read only>
sf
asdf
adsf
asdf
as
dfa
sdf
</textarea>
Or something like that, needless to say it didn't work because it only
made a tiny box.
I have a lot of text that needs to go within this box, so I want the
user to be able to read it and scroll up when they get to the bottom.
Thanks


Use <gasp choke> iframe if you must have scrollbars.
Otherwise you'll need some scripting to create a pseudo scroll effect.
 
R

rf

Richard said:
Use <gasp choke> iframe if you must have scrollbars.
Otherwise you'll need some scripting to create a pseudo scroll effect.

Er, what? A textarea has, by defult, scrollbars. The following will do
exactly what the OP wanted though it is not really proper use of a textarea
and as it expands to the entire canvas why put the stuff in a textarea
anyway. A better idea would be to use a div and overflow: auto; An even
better ideas would be to use the standard browser canvas (the <body> element
if you like).

form, textarea {width: 100%; height: 100%;}

<form action="">
<textarea readonly=readonly>
whatever
</textarea>
</form>



Cheers
Richard.
 
R

Richard

rf wrote:


form, textarea {width: 100%; height: 100%;}
<form action="">
<textarea readonly=readonly>
whatever
</textarea>
</form>

Correction to your post just to show I did test this out.


<form action="" >
<textarea readonly cols="50" rows="20">
whatever
</textarea>
</form>

This works in 4.0 transitional.
Do note the use of "cols" and "rows" in place of height and width.
As I have not really not worked with textarea before, I was under the
impression that this was one area that hadn't been improved upon in html.
But apparently has.
Thanks for the info. I might even put it to use someday.
 
R

rf

Richard said:
rf wrote:





Correction to your post just to show I did test this out.


<form action="" >
<textarea readonly cols="50" rows="20">
whatever
</textarea>
</form>

This works in 4.0 transitional.
Do note the use of "cols" and "rows" in place of height and width.
As I have not really not worked with textarea before, I was under the
impression that this was one area that hadn't been improved upon in html.
But apparently has.
Thanks for the info. I might even put it to use someday.

The OP's requirement is to have a textarea <quote>that will expand to fit
the user defined screen settings</quote>. Presumably this means expand to
fit the users canvas. This can not be done with HTML as per your example
above. It can only be done with CSS, as per my example.

Cheers
Richard.
 
R

Richard

I tried your method. It does not work as given. I changed cols to 100% and
it did not resize in accordance with browser width.
 
R

rf

Richard said:
I tried your method. It does not work as given.

You are correct. I threw it at a browser without a doctype, triggering
quirks mode. In quirks mode it works fine. In standards compliant mode the
height is (correctly) ignored. The offending textarea is, however, as wide
as the canvas.
I changed cols to 100% and
it did not resize in accordance with browser width.

Nor should it. According to the specs the value of the cols attribute is a
number. 100% is not a number, it is a length. The only way to specify a %
width for a textarea is with CSS.

Anyway, it really looks like the OP is out of luck using a textarea for this
:)

Cheers
Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top