DelphiFAQ Home Search:

How to prompt the user with an inputbox in Javascript

 

comments6 comments. Current rating: 4 stars (3 votes). Leave comments and/ or rate it.

Question:

Is there a Javascript function similar to the "InputBox" function in VBScript?

Answer:

Yes, use prompt(Question, Default) as shown below.

<script type="text/javascript">
<!--

var answer = prompt ("What is your age?","20");
alert ("You are " + answer + " years old.")

// -->
</script>

Comments:

2007-12-21, 07:28:30
anonymous from Netherlands  
rating
bedankt
2009-08-28, 07:12:14
anonymous from Canada  
Thanks. Found what I needed

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: