Jump to content

Copy Paste Script Not Working With Multiple.


Bears___

Recommended Posts

It doesnt work, it only copys the last one. i have about 20 of them.

<script>
function myFunction() {
  /* Get the text field */
  var copyText = document.getElementById("myInput1");

  /* Select the text field */
  copyText.select();
  copyText.setSelectionRange(0, 99999); /* For mobile devices */

   /* Copy the text inside the text field */
  navigator.clipboard.writeText(copyText.value);

  /* Alert the copied text */
  alert("Copied the text: " + copyText.value);
}
</script>

 

Link to comment
Share on other sites

document.getElementById("myInput1"); only returns a single element. You need to change the ID in order to select a different element.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...