Is there a way to have a confirm dialog box display the value a user typed in a text box on a form? (For example, if the user types 100.00, I'd like the dialog box display a message something like, "Confirm Amount. Click OK if $100.00 is the correct amount.")
Yes:
var amount = document.getElementById("textbox").value;
confirm("Confirm Amount. Click OK if $" + amount + " is the correct amount.")
EDIT: Here is a working example: http://jsbin.com/inoru/edit
Sure, you can just pass a string value to the dialog:
var str = "my msg";
confirm(str);
So to display your custom message, just get the value of the text box and append it to your message. For example:
var amount = jQuery("#myTextBox").val();
confirm("Click OK if " + amount + " is the correct amount");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With