Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:28:29+00:00 2026-06-07T09:28:29+00:00

I have a table set up in the following way, with each cell containing

  • 0

I have a table set up in the following way, with each cell containing a span and a textarea:

<table>
   <tr><td class="title">Original File</td></tr>
   <tr><td><span id='ogline' onscroll="og.scrollTop=scrollTop"></span><span><textarea onscroll="ogline.scrollTop=scrollTop" onkeyup="linenumber()" id='og' onfocusout="linenumber()"></textarea></span></td></tr>
</table>

Along with that I have the following CSS:

<style>
span {
  width:93%;
  height: 100%;
}
textarea {
  width:92%;
  height: 100%;
  border-style:solid;
  border-color:black;
  border-width:2px;
  font-size:13px;
}
table {
  width:100%;
  height:100%;
}
.title {
  height:5%;
  text-align:center;
  background-color:#009;
  color:white;
}
#ogline {
  padding-top:4px;
  overflow:auto;
  font-size:12px;
  line-height:14.99px;
  width:6%;
}
</style>

What I am trying to do is have the scroll bar of the span and the scroll bar of the textarea synch up. I’ve somewhat accomplished this using the onscroll event listener with the following code:

onscroll="og.scrollTop=scrollTop"
onscroll="ogline.scrollTop = scrollTop

This has somewhat accomplished what I want it to, with the span being about a line off of where it should be. The greatest problem I am having though is when I paste a large amount of text into the textarea. This almost completely doesn’t work, with both scrollbars being completely off until I hold one of the scrollbars down for a significant amount of time before the other scrollbar will try to play catch up with the other.

Any suggestions? Is there maybe a better approach to this issue that I should try? Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:28:30+00:00Added an answer on June 7, 2026 at 9:28 am

    This could work:

    var scrolling=false;
    
    function og_scroll(el)
    {
        if (scrolling && el!=scrolling) {
            return;
        }
        scrolling = el;
        var textareas = document.getElementsByTagName('textarea');
        for (var i=0; i<textareas.length; i++) {
            if (textareas[i].id.indexOf('og')==0) { // searching for id==og*
                textareas[i].scrollTop=el.scrollTop;
            }
        }
        scrolling = false;
    }
    
    function up(num)
    {
        var area = document.getElementById('og'+num);
        if (area.scrollTop > 0) {
            area.scrollTop -= 15;
        }
    }
    
    function down(num)
    {
        var area = document.getElementById('og'+num);
        if (area.scrollTop < area.scrollHeight) {
            area.scrollTop += 15;
        }
    }
    
    function fix_mouse_scroll() {
        var textareas = document.getElementsByTagName('textarea');
        for (var i=0; i<textareas.length; i++) {
            if (textareas[i].id.indexOf('og')==0) {
                if ("onmousewheel" in document) {
                    textareas[i].onmousewheel = fixscroll;
                } else {
                    textareas[i].addEventListener('DOMMouseScroll', fixscroll, false);
                }
            }
        }
    }
    
    function fixscroll(event){
        var delta=event.detail? event.detail : event.wheelDelta; // positive or negative number
        delta = delta>0 ? 15 : -15;
        event.target.scrollTop += delta;
        //console.log(delta, ' with ',event.target.scrollTop);
    }
    

    Html part:

    <tr><td> <span onmousedown='up(1)'>[UP]</span> <span onmousedown='down(1)'>[DOWN]</span> <textarea id='og1' onscroll="og_scroll(this);"></textarea></td></tr>
    <tr><td> <span onmousedown='up(2)'>[UP]</span> <span onmousedown='down(2)'>[DOWN]</span> <textarea id='og2' onscroll="og_scroll(this);"></textarea></td></tr>
    <tr><td> <span onmousedown='up(3)'>[UP]</span> <span onmousedown='down(3)'>[DOWN]</span> <textarea id='og3' onscroll="og_scroll(this);"></textarea></td></tr>
    

    The full html code is here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table set up to hold folders. Each folder has an ID
I have the following table my_table with primary key id set to AUTO_INCREMENT. id
I quite often have rows of code like the following: UPDATE my_table SET name
I have a table set up as follows id origin destination carrier_id so typical
We have a table set up as follows: |ID|EmployeeID|Date |Category |Hours| |1 |1 |1/1/2010
I have a mysql table field set as time type which stores data in
I have a table with white-space set to nowrap and columns widths restricted using
I have a table that displays a set of data. But when I try
I have a table that containts a set of columns one of it is
I have a MySQL database where the table was set up to store the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.