Simple copy to clipboard button triggers form submission
-
I hope anyone has an idea here. I used Magic tags to output some form results on a single line and wanted a simple solution to copy that line to the clipboard. So I inserted a little script as shown below:
<button onclick="myFunction()">Copy GCode</button> <script> function myFunction() { var copyText = document.getElementById("myOutput"); copyText.select(); document.execCommand("copy"); alert("Copied the text: " + copyText.value); } </script>
It works like a charm, but this action also triggers the form submission. Is there a way to bypass this? This form doesn’t need submission at all btw.
Thanks in advance ??
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Simple copy to clipboard button triggers form submission’ is closed to new replies.