Since COVID hit I started trying to learn some programming. I started learning C# and was able to build a computer app (not a good one, but it worked). This is just for fun and has been a blast trying to figure it out how all this works, but now I'm stuck... I now wanted to try to build the same type of thing but on a website.
Basically I want this.
TextBox1: "UserInput1"
TextBox2: "UserInput2"
TextBox3: "UserInput3"
[Copy Button]
When the user presses the copy button it copies the "UserInput" text to the users clipboard. Formatted like below.
"UserInput1", "UserInput2", "UserInput3"
Thanks to w3schools I was able to find this solution.
<html>
<body>
<input type="text" value="UserInput1" id="myInput">
<button onclick="myFunction()">Copy Button</button>
<script>
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();
copyText.setSelectionRange(0, 99999)
document.execCommand("copy");
alert("Copied the text: " + copyText.value);
}
</script>
</body>
</html>
Now if I want to add multiple text boxes to be copied how to do you program that? Below is how my brain thinks it should work, but doing this only copies the first UserInput.
<html>
<body>
<input type="text" value="UserInput1" id="myInput1">
<input type="text" value="UserInput2" id="myInput2">
<input type="text" value="UserInput3" id="myInput3">
<button onclick="myFunction()">Copy Button</button>
<script>
function myFunction() {
var copyText = document.getElementById("myInput1","myInput2", "myInput3");
copyText.select();
copyText.setSelectionRange(0, 99999)
document.execCommand("copy");
alert("Copied the text: " + copyText.value);
}
</script>
</body>
</html>
I'm sorry if this is an extremely dumb question but through all of my googling I cannot find a solution. I'm not looking a programming hand out here, but I am looking for an explanation on why this is not working, and what path I should go down to find a solution. Any help would be greatly appreciated.
If it is not possible to copy multiple text fields is it possible to have all "UserInput" fields fill in to one hidden text box that the the copy button copies from?