0% found this document useful (0 votes)
22 views

Experiment 5: Aim: Write A Program To Print Date Using Javascript Theory

Uploaded by

yash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Experiment 5: Aim: Write A Program To Print Date Using Javascript Theory

Uploaded by

yash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Experiment 5:

AIM: Write a program to print date using JavaScript


Theory:
JavaScript is a scripting language designed primarily for adding interactivity to Web pages and creating
Web applications. The language was first implemented by Netscape Communications Corp. in Netscape
Navigator 2 beta (1995). JavaScript is different from the Java language (developed in the 1990s at Sun
Microsystems). However, the two languages can interoperate well. Client-side JavaScript programs, or
scripts, can be embedded directly in HTML source of Web pages. (Note: There is also server-side
JavaScript, but it's beyond the scope of this FAQ collection.) Depending on the Web developer's intent,
script code may run when the user opens the Web page, clicks or drags some page element with the
mouse, types something on the keyboard, submits a form, or leaves the page.
JavaScript is an object-oriented language with prototypal inheritance.
The language supports several built-in objects, and programmers can create or delete their own objects.
Prototypal inheritance makes JavaScript very different from other popular programming languages such
as C++, C#, or Java featuring classes and classical inheritance. JavaScript does not have classes in the
C++ or Java sense. In JavaScript, objects can inherit properties directly from each other, forming the
object prototype chain.
JavaScript is widely supported. It is available in the following browsers:
• Netscape Navigator (beginning with version 2.0)
• Microsoft Internet Explorer (beginning with version 3.0)
• Firefox
• Opera
• Google Chrome
Any other browser whose vendor licensed or implemented JavaScript.
Program:.

<!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>&nbsp; <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:

AIM: Create validation Form in JavaScript..


<html>
<script>
function reset1()
{
x=confirm("It will clear all the text entered")
if(x==true)
{
document.form1.t1.value=""
document.form1.t2.value=""
document.form1.ta.value=""
document.form1.t3.value=""
document.form1.r1[0].checked=false
document.form1.r1[1].checked=false
document.form1.c1.checked=false
document.form1.c2.checked=false
document.form1.c3.checked=false
document.form1.c4.checked=false
document.form1.c5.checked=false
document.form1.c6.checked=false
document.form1.t1.focus()
}
}
}
}
</script>
<body bgcolor="lightblue" text="red" style="font-size:15pt;fontfamily:Garamond"
onload=document.form1.t1.focus()><center>
<h2>ENTRY FORM</h2></center>
<form name=form1 method=post >
<table name=tab cellspacing=30pt>
<tr><td align=left><h2>Enter your Name :</h2></td><td align=right><input
type=text name=t1 size=18>
<tr><td align=left><h2>Enter your Age :</h2></td><td align=right><input
type=text name=t2 maxlength=3 size=18>
<tr><td align=left><h2>Enter your Address :</h2></td><td align=right><textarea
name=ta rows=5 cols=15></textarea>
<tr><td align=left><h2>Sex :</h2></td><td align=left><input type=radio name=r1
value="female">Female<br>
<input type=radio name=r1 value=male>Male</td>
<tr><td align=left><h2>Languages Known :</h2></td><td
align=left><center>(select more than one)</center>
<input type=checkbox name=c1 value=c>C<br>
<input type=checkbox name=c2 value=c++>C++<br>
<input type=checkbox name=c3 value=vb>VB<br>
<input type=checkbox name=c4 value=java>JAVA<br>
<input type=checkbox name=c5 value=asp>ASP<br>
35
<input type=checkbox name=c6 value=others>OTHERS<br></td>
<tr><td align=left><h2>Enter your Password :</h2></td><td align=right><input
type=password name=t3 size=18>
</table><center>
<input type=button value=" reset "onClick=reset1()>
<input type=button value=" check "onClick=check()>
<h3>Before submitting the datas please click the check Button</h3>
<input type="submit" value=" submit "></center>
</form>
</body>
</html>

Output:

36

You might also like