0

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);
};

1 Answer 1

2

use this

function confirmFunc() {
var name = document.getElementById("namebox").value;
confirm("Please confirm that the following name is correct: " +name);
};
1
  • This works, thanks. I will accept your answer as soon as Stack Overflow lets me. Apr 10, 2014 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.