Posted by : Deepak Vasudevan Tuesday, October 07, 2008

Scripted Input Form in WebPages

I just came across a query in a forum where a user was asking about getting input from the user through a built messagebox like InputBox in VB. A few replies I observed were negative.. I just thought of sharing this with other readers that JavaScript does support something similar to InputBox in VB. It is called 'prompt' function.

Example:

<Script Language='JavaScript'>
var strUserName = prompt("What is your name?", "Internet User");
</Script>

This puts up a dialog for the user with the question 'What is your name' and the textbox is prefilled with the default value 'Internet User'. The user can edit the value and click OK. If the user presses CANCEL or hits ESCAPE button, a NULL is returned to the caller.

Warning: Web browser would warn and stop the script with a popdown information bar on encountering a scripted input and a user-level confirmation is required when this control is used on a webpage.

Popular Post

Blogger templates

Labels

Blog Archive

Followers

Blog Archive

Powered by Blogger.

- Copyright © Lavanya Deepak -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -