Wednesday 22 August 2012

javascript prompt | prompt in javascript

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. 
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: