Experiment 5: Aim: Write A Program To Print Date Using Javascript Theory
Experiment 5: Aim: Write A Program To Print Date Using Javascript Theory
<!DOCTYPE html>
<html>
<body>
<h1>My First JavaScript</h1>
<p>Click the button to display the date.</p><p id="demo"></p>
<button type="button" onclick="myFunction()">print date</button>
<script>
functionmyFunction() {
document.getElementById("demo").innerHTML = Date(); }
</script>
</body></html>
Output:
30
31
Experiment 6:
AIM: Write a program to Sum and multiply two numbers using JavaScript.
<html><head><script>
functionmyFunction() {
var y = document.getElementById("txt1").value; var z = document.getElementById("txt2").value; var x
= +y + +z;
document.getElementById("demo").innerHTML = x;
}
functionmul() {
var y = document.getElementById("txt1").value; var z = document.getElementById("txt2").value; var x
= +y * +z;
document.getElementById("demo").innerHTML = x;
}
</script></head>
<body>
<p>Click the button to calculate.</p><br/>
<br/>Enter first number:
<input type="text" id="txt1" name="text1" size="6px">Enter second number:
<input type="text" id="txt2" name="text2" size="6px"><br>
<button onClick="myFunction()">SUM</button> <button
onClick="mul()">Multiply</button><p id="demo"></p></body></html>
Output:
32
Experiment 7:
AIM: Write a program to Show use of alert, confirm and prompt box.
<html><head>
<title>java script</title>
<script type="text/javascript"><! —
function confirmation() { var answer = confirm("Welcome Fb.com?") if (answer){
alert("Welcome!") window.location =
"http://www.fb.com/hatemyself90"; }
else {
alert("Bye bye!!")
}}
//--><!--
function prompter() {
var reply = prompt("What's your name?", "")
alert ( "Nice to see you" + reply + "!") }
//--></script>
</head><body>
<h1 align="center"> Java Script Alert, Confirm and Prompt Box. </h1>
form style="height:200px; width:200px; background-color:#CC33 66;"><h3> Java Script Alert
Box.</h3>
<input type="button" onclick="alert('Are you sure you want to give us the deed to your house?')"
value="Confirmation Alert"></form>
<form style="height:200px; width:210px; background-color:#FF9999; margin-top:-220px; margin-
left:300px"><h3> Java Script Confirm Box.</h3>
<input type="button" onClick="confirmation()" value="Fb Login"></form>
<div style=" margin-top:-220px; background-color:#00FF66; height:200px; width:200px; margin-
left:600px;"><h3> Java Script Prompt Box.</h3>
<input type="button" onclick="prompter()" value="Say my name!"></div></body></html>
Output:
33
Experiment 9:
Output:
36