Scrolling Multiple Textarea in sync

Discussion in 'Javascript' started by stuart, Jul 14, 2004.

  1. stuart

    stuart Guest

    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
    stuart, Jul 14, 2004
    #1
    1. Advertising

  2. stuart wrote:

    > 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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jul 14, 2004
    #2
    1. Advertising

  3. 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

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Stuart Cochrane, Jul 14, 2004
    #3
  4. Martin Honnen, Jul 14, 2004
    #4
  5. Thanks Martin,
    I've been out of the office - the script was exactly what I needed.
    Stuart



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Stuart Cochrane, Jul 21, 2004
    #5
  6. stuart

    Wired Earp Guest

    Stuart Cochrane wrote:

    > 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.


    --
    Wired Earp
    Wunderbyte
    Wired Earp, Jul 21, 2004
    #6
  7. 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

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Stuart Cochrane, Jul 22, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Trans
    Replies:
    2
    Views:
    482
    Trans
    Dec 12, 2005
  2. Kai Grossjohann

    Sync scrolling of divs (not frames)

    Kai Grossjohann, Nov 12, 2003, in forum: Javascript
    Replies:
    5
    Views:
    197
    Thomas 'PointedEars' Lahn
    Nov 23, 2003
  3. Yang Li Ke

    textarea scrolling

    Yang Li Ke, Mar 6, 2004, in forum: Javascript
    Replies:
    0
    Views:
    89
    Yang Li Ke
    Mar 6, 2004
  4. Mark
    Replies:
    5
    Views:
    281
    Mark Szlazak
    Mar 5, 2005
  5. Scrolling textarea in Opera

    , Dec 22, 2005, in forum: Javascript
    Replies:
    5
    Views:
    141
Loading...

Share This Page