H I O X INDIA
Javascript Tutorial
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





Window Prompt Method


Topic

How can I get some input from user using javascript?
or
How to use prompt method for getting data in javascript?



Explanation

Object: Window

Method or Function: prompt(string)

Description: This method is used for getting dynamic user input or data. It takes the message as argument. User is prompted with input box to enter the data.

Example: For an example we will prompt a message box asking for his name. Once the user enters the name we will get it and show it in the text field.


Example Code:
<form name=tett>
<input type=text name=tf value="testing prompt" size=15>
</form>

<script language=javascript>
var df = prompt(" enter your name ");
document.tett.tf.value = df;
</script>

Result:


Explanation:
In the above example,
  • first we created a form named tett.
  • form containing a text and button.
  • in the javascript code, we invoke a prompt box with a message.
  • we get the user input in the variable named df.
  • we set the name as value to the text field tf.



  •         Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

    others

    privacy policy     license     sitemap
    © 2004-2005 HIOX INDIA - hioxindia.com

    Other Links