JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" value="Red" id="myInput">
<input type="text" value="Blue" id="myInput2">
<input type="text" value="Black" id="myInput3">
<input type="hidden" value="" id="output">
<button onclick="myFunction()">Copy text</button>
<script>
function myFunction() {
var copyText = document.getElementById("myInput");
var copyText2 = document.getElementById("myInput2");
var copyText3 = document.getElementById("myInput3");
var output = document.getElementById("output");
output.value = copyText.value + "_" + copyText2.value + "_" + copyText3.value;
output.select();
document.execCommand("copy");
}
</script>