Previous
Left Arrow
Use the tab key in a textarea
Current Code Entry
Go Back To Code List
[How-To]
  • Insert text from 2 inputs into a TextArea a cursor position

    Article Entry Date: October 31,2022 @ 09:01:11 / Last Updated On: February 4,2026 @ 10:52:18
  • Insert text from 2 inputs into a TextArea a cursor position : Image Name | CFF Coding Source
    Insert text from 2 inputs into a TextArea a cursor position
The BBCode editor allows you to select specific text from a textarea, have that text inserted into an Input field, and then add a URL string back to the textarea.
This code can be used on forum-style websites, making it easy to add URLs to your visitors' posts.

Origins
  1. September 02, 2010 - Originally posted and shared with the Coding Source Community.
  2. June 20, 2012 - Updated form elements and code
  3. October 31, 2022 - Updated with selected text in Textarea.
    Original code source to Selected text (javascriptkit.com«)
    To work with an [Input] field instead of DIV, code provided by: Michel Plungjan«
  4. Wednesday, February 3, 2026 10:32 PM EST - I had to change the document.myform.txta -to- document.myform.code
    It used to work with the name, but now it only works with the ID. Strange.
  5. When viewing the Code Example. Please follow the instructions located at the top of the Code Editor.
    For the Insertion to work, you will first need to
    Click inside this area, and press a key (Spacebar is the preferred method)
    This will activate the Form and make it work.