In my code I have 3 input fields. I would like to to copy the values in these input fields to my clipboard seperated by a underscore.
Example: Red_Blue_Black
The issue is, my code only copies one of the inputs and I dont know how to separate the values with a underscore when I copy it.
<!DOCTYPE html>
<html>
<body>
<p>Click on the button to copy the text from the text field. Try to paste the text (e.g. ctrl+v) afterwards in a different window, to see the effect.</p>
<input type="text" value="Red" id="myInput">
<input type="text" value="Blue" id="myInput2">
<input type="text" value="Black" id="myInput3">
<button onclick="myFunction()">Copy text</button>
<p>The document.execCommand() method is not supported in IE8 and earlier.</p>
<script>
function myFunction() {
var copyText = document.getElementById("myInput");
var copyText2 = document.getElementById("myInput2");
var copyText2 = document.getElementById("myInput3");
copyText.select();
copyText2.select();
copyText3.select();
document.execCommand("copy");
}
</script>
</body>
</html>