Given the following HTML:
<div id= "playerNames" class="playerInfo">
<form name="form1" method="post" action="http://examples.funwebdev.com/process.php" id="newGame">
<p id= "userInput">
<label>Player 1 name: </label></br><input type="text" name="p1" id="nameOne" value="" required></input></br>
<label>Player 2 name: </label></br><input type="text" name="p2" id="nameTwo" required></input> <input id="submit" type="submit" value="New Game"/>
</p>
</form>
</div>
And the following javascript:
$(document).ready(function () {
console.log("jQuery is ready to use...");
$("#newGame").on("submit", newGameListener);
});
function setUpUsers(){
var player_One = document.getElementById("nameOne").value;
var player_Two = document.getElementById("nameTwo").value;
document.getElementById("pTurns").innerHTML = (+nameTwo+ ", its your turn");
document.getElementById("pScores").innerHTML = (+nameOne+ ": 50pts </br>" (+nameTwo+ ": 50pts </br>"
}
function newGameListener(e) {
e.preventDefault();
setUpUsers();
}
I am trying to append these two variables (nameOne, nameTwo) within p elements. However when this code is run I get NaN (Not a Number) Instead of the user input as a string. Not sure how I should go about achieving this!
(+nameOne+ ": 50pts </br>" (+nameTwo+