How to write javascript in html pages with using prompt.
<html>
<head>
<script type="text/javascript">
x=prompt("Enter your date of birth:" ,",");
y=Date.parse(x);
today=new Date();
age1=(today-y);
alert("Your age is:"+age1+"milliseconds");
age=age1/(1000*60*60*24*365);
alert("Age is:"+Math.round(age)+"years");
</script>
</head>
<body>
</html>
How to use prompt in javascript
<script>
function fun1()
{
x=prompt("enter a number");
y=prompt("enter a number");
alert(parseInt(x)+parseInt(y))
}
</script>
<body>
<input type="button" value="click" onclick="fun1()">
</body>
Before calling fun1() just create a function then use in script.
<html>
<head>
<script type="text/javascript">
x=prompt("Enter your date of birth:" ,",");
y=Date.parse(x);
today=new Date();
age1=(today-y);
alert("Your age is:"+age1+"milliseconds");
age=age1/(1000*60*60*24*365);
alert("Age is:"+Math.round(age)+"years");
</script>
</head>
<body>
</html>
How to use prompt in javascript
<script>
function fun1()
{
x=prompt("enter a number");
y=prompt("enter a number");
alert(parseInt(x)+parseInt(y))
}
</script>
<body>
<input type="button" value="click" onclick="fun1()">
</body>
Before calling fun1() just create a function then use in script.
0 comments: