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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:51:37+00:00 2026-05-27T18:51:37+00:00

Well guys, i was just doing a simple stuff of executing system copy, delete

  • 0

Well guys, i was just doing a simple stuff of executing system copy, delete etc. commands using execCommand method of js.

I have made two textareas and by hitting on the buttons i am executing copy, cut etc. commands.

Problems:

  1. In this the paste button is not working. Like i am copying some text from one textarea, it is not pasting into other textarea.

  2. Also I want to do select all for the textareas only. Like if cursor is on textarea1 and if I am hitting on selectAll button it should only select the textarea1 content. Currently it is selecting the whole page content.

Code:

  <script language="javascript">
    function doCopy()
   {
        document.execCommand('Copy',false,0);
   }
   function doPaste()
   {
        document.execCommand('Paste');
   }
   function doCut()
   {
        document.execCommand('Cut',false,0);
   }
   function doSelectAll()
   {
        document.execCommand('SelectAll',false,0);
    }
  function doDelete()
   {
        document.execCommand('Delete',false,0);
   }
    function doUndo()
    {
        document.execCommand('Undo',false,0);
    }
    function doUnselect()
    {
        document.execCommand('Unselect',false,0);
    }
  </script>
 </head>
<body>
<div align="center">
  input values : ---- <br>
 <textarea align="left" id="txtArea" name="txtArea" style="width:300px;         height:50px"></textarea>
 <br>
  <input type="button" id="btnCopy" name="btnCopy" value=" Copy " onclick="doCopy()" />
  <input type="button" id="btnCut" name="btnCut" value=" Cut " onclick="doCut()" />
  <input type="button" id="btnSelectAll" name="btnSelectAll" value=" Select All " onclick="doSelectAll()" />
  <input type="button" id="btnPaste" name="btnPaste" value=" Paste " onclick="doPaste()" />
  <input type="button" id="btnDelete" name="btnDelete" value=" Delete " onclick="doDelete()" />
 <input type="button" id="btnUndo" name="btnUndo" value=" Undo " onclick="doUndo()" />
 <input type="button" id="btnUnselect" name="btnUnselect" value=" Undo " onclick="doUnselect()" />
  <br>
  Manipulate <br>
  <textarea align="left" id="txtArea1" onpaste="alert('yes');" name="txtArea1" style="width:300px;height:70px" ></textarea>
   </div>

I am doing this for IE9.

  • 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-27T18:51:37+00:00Added an answer on May 27, 2026 at 6:51 pm

    I had to make major changes I hope it will be OK for you.
    This solution requires jquery. I have tested it with Chrome and Firefox but I dont have IE9.

        var copy = "";
        var focused_field = null;
        $("#btnCopy").click(function(){
            //set copy variable to the selected text
            txtArea = document.getElementById("txtArea");
            var start = txtArea.selectionStart;
            var end = txtArea.selectionEnd;
            copy =  $(txtArea).val().substring(start, end);
        });
        $("#btnCut").click(function(){
            //set copy variable to the selected text and cuts it
            txtArea = document.getElementById("txtArea");
            var start = txtArea.selectionStart;
            var end = txtArea.selectionEnd;
            copy =  $(txtArea).val().substring(start, end);
            $(txtArea).val(
                $(txtArea).val().substring(0,start)+
                $(txtArea).val().substring(end)
            );
        });
       $("textarea").focus(function(){focused_field = $(this);});
        $("#btnSelectAll").click(function(){
            //select all in focused field
            if(focused_field)
                focused_field.select();
        });
        $("#btnPaste").click(function(){
            //paste copyed text to manipulate field
            txtArea1 = document.getElementById("txtArea1");
            $(txtArea1).val($(txtArea1).val()+copy);
        });
    

    Here is the example.

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

Sidebar

Related Questions

Hey guys, I'm using Twitter's PHP API, called twitterlibphp , and it works well,
I'm doing some data analysis over the judge appointment system in France, and using
Hey guys. Just wondering if anyone knows of a method to create sparkline graphs
Well guys, it's a simple question (more than a question i'ts a challenge). When
Well guys, this problem just baffles me. I hope someone can explain to me
Well... simple question, right? But with no so simple answers. In firefox i use
Well, it seems simple enough, but I can't find a way to add a
Hi guys I'm using this wonderful class here to do a bit of code
What is the difference between using Rfc2898DeriveBytes and just using Encoding.ASCII.GetBytes(string object); ? I
ok, so I made this and this works just fine and well: $file_name =

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.