Hi,
In this post i will explain java script boxes
Lets come...
Java Scrript box are clasified in three ways
Input Box
2. Use html form element
Syntax:
prompt("enter you text here",'');
You get input from a user using above syntax, and that value process another use you must assign varibale in following way
var a=prompt("enter A value",'');
var b=prompt("enter B value",'');
Example:
<html>
<head>
<script type="text/javascript">
function get()
{
var a=prompt("Enter the A value:",'');
var b=prompt("Enter the B value:",'');
var c=parseInt(a)+parseInt(b);
document.getElementById("ans").innerHTML="The Result is"+c;
}
</script>
<title>Untitled Document</title>
</head>
<body>
<h1 id="ans"></h1>
</body>
</html>
Output:
Note:
The above example placed parseInt. parseInt is ised to convert string to integer. The prompt return input is a string if you use this value in calculation the way be concat the two values ex: 25,50 the answer reurn to 2550. But you must convert integer value. parseInt method convert the string to integer.
Warning Box:
Syntax:
alert("Welcome");
Example:
The body loaded time msg box will apper you call the function in onload event. the function just write the above method.
<html>
<head>
<script type="text/javascript">
function show()
{
alert("Wlcome to my blog");
}
</script>
<title>Untitled Document</title>
</head>
<body onload="show()">
</body>
</html>
In this post i will explain java script boxes
Lets come...
Java Scrript box are clasified in three ways
- Input Box
- Warning Box
- Conform Box
Input Box
- Basically you get input from a user there are two ways in javascript
2. Use html form element
- Input box are used to get input from a user.
- Java script using 'promt' Its used get input from a user.
Syntax:
prompt("enter you text here",'');
You get input from a user using above syntax, and that value process another use you must assign varibale in following way
var a=prompt("enter A value",'');
var b=prompt("enter B value",'');
Example:
<html>
<head>
<script type="text/javascript">
function get()
{
var a=prompt("Enter the A value:",'');
var b=prompt("Enter the B value:",'');
var c=parseInt(a)+parseInt(b);
document.getElementById("ans").innerHTML="The Result is"+c;
}
</script>
<title>Untitled Document</title>
</head>
<body>
<h1 id="ans"></h1>
<input type="submit" name="submit" value="get input" onclick="get()" />
</body>
</html>
Output:
Note:
The above example placed parseInt. parseInt is ised to convert string to integer. The prompt return input is a string if you use this value in calculation the way be concat the two values ex: 25,50 the answer reurn to 2550. But you must convert integer value. parseInt method convert the string to integer.
Warning Box:
- Javascript warning box used to warn the user.
- And also used to like message box.
- Javascript it achives alert method.
Syntax:
alert("Welcome");
Example:
The body loaded time msg box will apper you call the function in onload event. the function just write the above method.
<html>
<head>
<script type="text/javascript">
function show()
{
alert("Wlcome to my blog");
}
</script>
<title>Untitled Document</title>
</head>
<body onload="show()">
</body>
</html>
Output is:
Confirm Box:
- Confirm box are used to confirm the user input. If may be change any value we can use confirm box.
- Confirm box return Boolean(true/false)
- Confirm box apper in ok cancel button, you may select ok it return true, select cancel it return false,
Syntax:
confirm("enter you text here");
Example:
<html>
<head>
<script type="text/javascript">
function get()
{
var c=confirm("do you want any change");
if(c==true)
{
document.getElementById("ans").innerHTML="You select OK";
}
else
{
document.getElementById("ans").innerHTML="You select Cancel";
}
}
</script>
<title>Untitled Document</title>
</head>
<body>
<h1 id="ans"></h1>
<input type="submit" name="submit" value="get input" onclick="get()" />
</body>
</html>
Output is:
The above three boxes are used to often in javascript. You want any place use this boxex
I hope this useful to you
Thanks
No comments:
Post a Comment