So, this is my first post here and I am pretty new to coding in general so bear with me. I am trying to get user input from two different textboxes and interweave them once a button is clicked. So if the user enters "abcd" in the first textbox and "1234" in the second, the result would be "a1b2c3d4" in the last textbox. Here is my code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<label>Enter Text Here:</label>
<input id="userInput1" type="text" />
<label>Enter Text Here:</label>
<input id="userInput2" type="text" />
<button id="myBTN" type="button">Try it</button>
<label for="output">Result: </label><input id="output" type="text"/>
<script type="text/javascript" src="jscript.js"></script>
</body>
</html>
And my Javascript:
var myButton = document.getElementById("myBTN");
myButton.addEventListener("click", merge);
function merge() {
var a = document.getElementById("userInput1").value;
var b = document.getElementById("userInput2").value;
var aMod = a.split("");
var bMod = b.split("");
var c = ""
for (i=0; i < aMod || i < bMod; i++) {
if (i < aMod)
c += aMod[i];
if (i < bMod)
c += bMod[i];
}
return c;
document.getElementbyId("output").value = "c";
}
I'm not getting any errors when I try to execute it, but nothing will happen when I click the button. Any help is appreciated.