Dynamic resizing of an object (SPAN or else)

D

DL

Hi,

I haven't started coding yet but would like to think it through
first. What I'd like to do for the task is,
(1) display some text (approximately 300 to 1000 characters), to be
contained in either SPAN or DIV.

(2) then provide a small textarea input box/area right below it to
allow the user to input additional stuff, once complete. Info, we
don't know how much data the user is going to input into the Textarea.

(3) hide (1), that is, the SPAN or DIV in question and resize the
current textarea so that the extra spaces previously occupied by the
SPAN or DIV would disappear and now we have a read-only area that
displays the data inputted at step (2).

Question, how to dynamically determine the current size of the small
Textarea at this point?

Many thanks. Please let me know if I've not clearly described the
problem.
 
T

Thomas 'PointedEars' Lahn

DL said:
I haven't started coding yet but would like to think it through
first. What I'd like to do for the task is,
(1) display some text (approximately 300 to 1000 characters), to be
contained in either SPAN or DIV.

(2) then provide a small textarea input box/area right below it to
allow the user to input additional stuff, once complete. Info, we
don't know how much data the user is going to input into the Textarea.

(3) hide (1), that is, the SPAN or DIV in question and resize the
current textarea so that the extra spaces previously occupied by the
SPAN or DIV would disappear and now we have a read-only area that
displays the data inputted at step (2).

Question, how to dynamically determine the current size of the small
Textarea at this point?

Many thanks. Please let me know if I've not clearly described the
problem.

I think your question is moot, because this reads to me like one big design
error at first glance. What do you think you need this for?


PointedEars
 
D

DL

I think your question is moot, because this reads to me like one big design
error at first glance.  What do you think you need this for?

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

" big design error". No. Do not assume you understand design. Either
you are able and willing to answer the question or not.
 
T

Thomas 'PointedEars' Lahn

DL said:
Thomas said:
DL said:
I haven't started coding yet but would like to think it through ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
first. What I'd like to do for the task is, ^^^^^^
(1) display some text (approximately 300 to 1000 characters), to be
contained in either SPAN or DIV.

(2) then provide a small textarea input box/area right below it to
allow the user to input additional stuff, once complete. Info, we
don't know how much data the user is going to input into the Textarea.

(3) hide (1), that is, the SPAN or DIV in question and resize the
current textarea so that the extra spaces previously occupied by the
SPAN or DIV would disappear and now we have a read-only area that
displays the data inputted at step (2).

Question, how to dynamically determine the current size of the small
Textarea at this point?

Many thanks. Please let me know if I've not clearly described the
problem.

I think your question is moot, because this reads to me like one big
design error at first glance. What do you think you need this for?
[...]

" big design error". No.

Yes, that is exactly how it reads to me.
Do not assume you understand design.

Pot, kettle, black.
Either you are able and willing to answer the question or not.

Your use case does not make sense, and so your question. Obviously you
have a lot more "thinking through" to do. Good luck with your "task",
then; you're going to need it.


HAND

PointedEars
 
S

Scott Sauyet

 What I'd like to do for the task is,
(1) display some text (approximately 300 to 1000 characters), to be
contained in either SPAN or DIV.

(2) then provide a small textarea input box/area right below it to
allow the user to input additional stuff, once complete.  Info, we
don't know how much data the user is going to input into the Textarea.

(3) hide (1), that is, the SPAN or DIV in question and resize the
current textarea so that the extra spaces previously occupied by the
SPAN or DIV would disappear and now we have a read-only area that
displays the data inputted at step (2).

Question, how to dynamically determine the current size of the small
Textarea at this point?

This doesn't sound hard. Find the position of the top of the SPAN/DIV
(x), the position of the top of the TEXTAREA (y), and the height of
the TEXTAREA (z), then set the height of the TEXTAREA to z + (y - x).

I'm with Thomas, though. Why turn the control to read-only? Why hide
the introductory material? It does not sound particularly usable.

-- Scott
 
D

Dr J R Stockton

In comp.lang.javascript message <1d4f252a-d818-456f-8fbb-10b188da512d@t3
1g2000prh.googlegroups.com>, Fri, 12 Feb 2010 21:40:17, DL
" big design error". No. Do not assume you understand design. Either
you are able and willing to answer the question or not.

It is a mistake to treat Thomas as a normal human being. Do not
attempt it.

If read with reasonable care, your first post explains exactly what you
want to do. It is easy enough, with the possible exception of deciding
how many lines of the textarea are to be retained. That depends on how
your textarea deals with wrap; IIRC there are at least three
possibilities that can be set.

I do similar in some of my pages.

There is one minor problem with textarea, as I recall, which perhaps you
will not be bothered about : in my 5 browsers, when rows is set to N,
some make room for N rows and some for N+1.

An alternative to textarea might to be to add an onKey... event to an
empty focused <p> element, type into it, and remove the event handling
when finished. The area should then be correctly sized and readonly.

If still present and interested, respond here, saying how you know when
the user has finished his text entry.
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,259
Latest member
JorjaBurne

Latest Threads

Top