JAVASCRIPT VARIABLE
Variables are run time entity that is used to store data during run time and in JavaScript we have to use "var" keyword to declare any variable.
RULES FOR NAMING VARIABLE
1. Every variable should be declare with "var" keyboard.
Example: var a;
2. Variable names should be always start with a character.
Example: var a, var b12, var abc;
3. Blank spaces are not allow in any variable name
Example: var roll_no;
4. Variable cannot declare with reserve keywords such var, break, for, name
Example: var name1;
SIMPLE JAVASCRIPT PROGRAM
<script>
document.write("Hello Wolrd");
</script>
Explanation: In the above program <script> tag is used to insert java script code, "document.write" is a java script command that is used to print any given argument on output window and "Hello Word" is text argument.
Example: Program to enter input from user
<html>
<title> Access text box value </title>
<body>
<form name="f">
Enter any number <input type="text" name="n">
<input type="button" value="Submit" onclick="abc()">
</form>
<script>
function abc()
{
alert(f.num.value)
}
</script>
</body>
</html>
0 Comments