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 9200751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:50:14+00:00 2026-06-17T22:50:14+00:00

The textarea in my form, id=Fulltext, is fed by database with many chapters of

  • 0

The textarea in my form, id=”Fulltext”, is fed by database with many chapters of a book.
When the user clicks a link above the text area,
<a href="samePage.php?chap=Chapter 5" id="Chapter 5">Chapter 5</a>, I would like the cursor to move inside the textarea and position itself in front of the text, ‘Chapter 5’.
Is this possible?

  • 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-17T22:50:15+00:00Added an answer on June 17, 2026 at 10:50 pm

    DEMO: http://jsfiddle.net/deg6j/

    HTML

    <html>
    <head>
        <script type="text/javascript">
            function selectText(text)
            {
                var textArea = $('#Fulltext');
                var index = textArea.text().search(text);
                textArea.caretTo(index);      
            }
        </script>
    </head>
    <body>
    <textarea id='Fulltext' rows=10>
        Chapter 1
        This is a lot of text...
    
        Chapter 2
        More more more
    
        Chapter 3
        More dsa less
    </textarea>
        <a href="#" onclick="selectText('Chapter 2')">Chapter 2</a>
    </body>
    </html>
    

    Javascript

    new function($) {
      // Behind the scenes method deals with browser
        // idiosyncrasies and such
        $.caretTo = function (el, index) {
            if (el.createTextRange) { 
                var range = el.createTextRange(); 
                range.move("character", index); 
                range.select(); 
            } else if (el.selectionStart != null) { 
                el.focus(); 
                el.setSelectionRange(index, index); 
            }
        };
    
        // The following methods are queued under fx for more
        // flexibility when combining with $.fn.delay() and
        // jQuery effects.
    
        // Set caret to a particular index
        $.fn.caretTo = function (index, offset) {
            return this.queue(function (next) {
                if (isNaN(index)) {
                    var i = $(this).val().indexOf(index);
    
                    if (offset === true) {
                        i += index.length;
                    } else if (offset) {
                        i += offset;
                    }
    
                    $.caretTo(this, i);
                } else {
                    $.caretTo(this, index);
                }
    
                next();
            });
        };
    }(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I go about posting a textarea form? <form method=post action=/user/test/shoutbox/add id=shoutPost class=clearit>
I have a textarea form which takes a large block of text. In this
I have some code that when a user clicks on a link Add Comment,
I am using php5. I am doing a form, a textarea, where user can
How do I put initial text into a Spring form textarea? The TLD rejects
I have a textarea form in my html. If the user hits enter between
I'm using a HTML form's TEXTAREA field that will contain text and it may
How do I edit the selected text of a textarea form element? EDIT: as
I've got a basic textarea form. What i'm trying to do is remove all
I would like to use a textarea in html form to get the delimited

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.