I am trying to get multiple values of the buttons displayed next to each other in "field2" when you select them. I could not find out how to combine them in a working way...
function myFunction() {
document.getElementById("field2").value = document.getElementById("field1").value;
}
<!DOCTYPE html>
<html>
<body>
<input class="calculator" type="button" id="field1" value=1 onclick="myFunction()">
<input class="calculator" type="button" id="field1" value=2 onclick="myFunction()">
<input class="calculator" type="button" id="field1" value=3 onclick="myFunction()"><br>
<input class="calculator" type="button" id="field1" value=4 onclick="myFunction()"> .....
<br> Code: <input type="text" id="field2"><br><br>
</body>
</html>
field1for all the buttons.