I am trying to get a confirmation box to display my input data from a textbox, but instead of whatever I put in, the confirmation box displays "null" where the input is supposed to be. Please help. I tried adding .val() to name in the confirmation box, but no luck. JSFiddle
HTML:
First Name: <input type="text" id="namebox">
<input type="submit" id="submitbutton" onClick="confirmFunc()">
JS:
function confirmFunc() {
var name = document.getElementById("#namebox");
confirm("Please confirm that the following name is correct: " +name);
};
use this
function confirmFunc() {
var name = document.getElementById("namebox").value;
confirm("Please confirm that the following name is correct: " +name);
};