DelphiFAQ Home Search:

How to prompt the user with an inputbox in Javascript

 

comments15 comments. Current rating: 4 stars (7 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
2010-03-20, 01:50:05
anonymous  
rating
dxfg
2010-03-20, 01:55:54
anonymous  
fgfdg
2010-04-20, 08:07:58
anonymous from Romania  
re
2011-11-12, 15:49:40
anonymous from Hungary  
rating
2011-11-13, 21:37:13
ccaror@gmail.com from Uruguay  
rating
thanks!
2012-01-23, 12:11:36
anonymous from Turkey  
Thank you very much i'm turk its very worked for me :)
2012-04-13, 12:31:23
anonymous from India  
thank you very much
2012-05-15, 08:58:46
anonymous from Germany  
rating
Thanks!
2012-06-14, 03:18:28
Kyler from Sydney, Australia  
rating
Awesome man now I can use it in my Text Game Thx a lot again
2013-06-12, 21:09:21
christian from Bolivia  
thanks!!....
2013-06-21, 06:43:42
anonymous from France  
Great :> !
2017-11-27, 19:46:15
anonymous from Indonesia  

 

 

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: