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

  • Home
  • SEARCH
  • 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 7603179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:36:07+00:00 2026-05-30T23:36:07+00:00

When I select some texts on the <textarea> using my mouse, how can I

  • 0

When I select some texts on the <textarea> using my mouse, how can I shuffle/scramble it by clicking on a button?

I’ve searched for something similar to what I want here on SO, and I saw some who use substring, selectionStart, and selectionEnd.

What I want is: when I select some texts with my mouse, it will be shuffled/scrambled when I click on a button, and the rest of the texts on the <textarea> that are not selected should remain untouched/intact.

I just want to perform an action on the selected texts.

It’s more similar to a rich text editor like when you select on some texts, then click on bold button, the selected texts will become bold.

P.S.
It should be shuffled by individual characters.

EDIT:
Got it! I just needed to separate the selection string. My code works now. This is very helpful – https://stackoverflow.com/a/9605191/1101391

Unfortunately, IE 9 and below does not support selectionStart and selectionEnd properties on <input> and <textarea>. Here’s the solution that worked for me – https://stackoverflow.com/a/9276457/1101391

  • 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-05-30T23:36:07+00:00Added an answer on May 30, 2026 at 11:36 pm

    You have access to the full text and know the substring where the selection starts and ends. Try something like this:

    var txtArea = document.getElementById("foo");
    var before = txtArea.value.substr(0, txtArea.selectionStart);
    var selection = txtArea.value.substr(txtArea.selectionStart, txtArea.selectionEnd + 1);
    var after = txtArea.value.substr(txtArea.selectionEnd, txtArea.value.length);
    txtArea.value = before + scrambleThisString(selection) + after;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox and a link button. When I write some text, select
Are there any attributes to pre select some radio button in tag on page
There is a common feature of modern browsers where a user can select some
I have a gtk.Textview . I want to find and select some of the
if i have one form that include some input, textarea, select, and multiple file.
For some reason, I can't get rgba working within my CSS using IE9. I've
I'm working on a new project and i want to do something similar (somehow)
I'm trying to select some integer values in MySQL. Several of the values are
my table has the following fields videos |id| |average| |views| now i select some
Drupal's UberCart is a solution, where you select some product manually and then click

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.