Scrolling Multiple Textarea in sync

S

stuart

I have two textareas on a HTML page. If a user scrolls in one textarea
I want the other textarea to scroll as well. In otherwords I want both
textareas to scroll up and down in unison.

Can anyone help.

Thanks

Stuart
 
M

Martin Honnen

stuart said:
I have two textareas on a HTML page. If a user scrolls in one textarea
I want the other textarea to scroll as well. In otherwords I want both
textareas to scroll up and down in unison.

<form ...>
<texarea onscroll="this.form.elements.textarea2.scrollTop =
this.scrollTop;" name="textarea1" ...></textarea>
<textarea onscroll="this.form.elements.textarea1.scrollTop =
this.scrollTop;" name="textarea2" ...></textarea>
</form>
should work with IE to synchronize vertical scrolling.
Mozilla has a bug with onscroll for <textarea> elements so that is
doesn't work there:
http://bugzilla.mozilla.org/show_bug.cgi?id=229089
I also do not get any onscroll handler to fire with Opera 7 here.
 
S

Stuart Cochrane

Hi Martin,

i have tried adding the code to my page but it is not working - i am
using ie6. do i need to add anything else to the code ?

Here is the code:


<td align=center>
<textarea rows="50"
onscroll="this.form.elements.interim_feedback.scrollTop =
this.scrollTop;" cols="45" name="accountabilities_and_measures" style="
font-family:Arial, Helvetica, sans-serif;color:black; font-size:
8pt"><%= accountabilities_and_measures %></textarea>
</td>
<td align=center>
<textarea rows="50" cols="45"
onscroll="this.form.elements.accountabilities_and_measures.scrollTop =
this.scrollTop;" name="interim_feedback" style=" font-family:Arial,
Helvetica, sans-serif;color:black; font-size: 8pt"><%= interim_feedback
%></textarea>
</td>

Thanks

Stuart
 
S

Stuart Cochrane

Thanks Martin,
I've been out of the office - the script was exactly what I needed.
Stuart
 
W

Wired Earp

Stuart said:
Thanks Martin,
I've been out of the office - the script was exactly what I needed.
Stuart

If you are desperate for Mozilla support, you can hack up a solution by
listening for "curpos" transmissions from the DOMAttrModified event. Let me
know if this is the case.
 
S

Stuart Cochrane

Hi,

Is it possible to increase the synchronisation and force the second
textarea to start scrolling even when there is nothing in it? In other
words as a row is created in the first textarea can we automatically
create a row in the second - this would ensure that both text boxes have
exactly the same number of rows and force synchronisationb.

Thanks for any help

Stuart
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top