Copy all form field values to Clipboard

Copy all form field values to Clipboard

I am developing a form, that once complete, will have a button that copies ALL form field values to the clipboard, to be pasted in an offline document

I have figured out how to do this for one field, but get nowhere when trying to add multiple values.

I have read about getElementsByClassName, and document.querySelector, but also, can get neither to work,

Below is my working code for only one field:

***********************************
<input type="text" value="" id="Field1">
<button onclick="myFunction()">Copy text</button>



<script>
function myFunction() {
  var copyText = document.getElementById("Field1");
  copyText.select();
  document.execCommand("copy");
  alert("Copied the text: " + copyText.value);
}
</script>
***********************************