Search code examples
javascriptinputpopupprompt

Passing the input value of prompt boxes


Is it possible to pass a input value of prompt box like this?

<script type="text/javascript">
function prompt_box()
{
var naam=prompt("Please enter your name:","Type your name here.")
document.location = 'delete.php?target=' + naam;
}
</script>

Or do I have to use a form?


Solution

  • That is the correct way of passing the value returned from prompt to a variable.

    var value = prompt("Please enter your name:", "Type your name here.");