0% found this document useful (0 votes)
4 views4 pages

Javascript

The document contains multiple JavaScript and HTML snippets for different functionalities. It includes a passenger management system that displays user information, a car details display based on user selection, an age calculator based on date of birth input, and a function to calculate the sum of a series. Each section is structured with corresponding HTML for user interaction and JavaScript for processing data.

Uploaded by

Komal Tuli
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)
4 views4 pages

Javascript

The document contains multiple JavaScript and HTML snippets for different functionalities. It includes a passenger management system that displays user information, a car details display based on user selection, an age calculator based on date of birth input, and a function to calculate the sum of a series. Each section is structured with corresponding HTML for user interaction and JavaScript for processing data.

Uploaded by

Komal Tuli
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/ 4

1st

Index .js​
function callMe() {
var name = "Arun";

var age = 28;

var reservedStatus = true;

String(name);

Number(age);

Boolean(reservedStatus);

document.write("<div id='name'>"+name+"</div>");

document.write("<div id='age'>"+age+"</div>");

document.write("<div id='reservedStatus'>"+reservedStatus+"</div>");

Index.html​
<html></html>
<head>

<title>Passenger Management</title>

<script src="index2.js"></script>

</head> <body>

<button onclick="callMe()">Show</button >

</body> </html>

2nd

index.js
let carDetails = [
["Innova", "900000", "2016"],
["Dzire", "700000", "2017"],
["i20", "500000", "2013"],
["i10", "400000", "2016"]
];
function displayCarDetails() {
var x = document.getElementById('SelectCar').value;

if (x == "Innova") {
document.getElementById('CarDetail').innerHTML = carDetails[0][0] +
"_" + carDetails[0][1] + "-" + carDetails[0][2];
}
else if (x == "Dzire") {
document.getElementById('CarDetail').innerHTML = carDetails[1][0] +
"_" + carDetails[1][1] + "-" + carDetails[1][2];
}
else if (x == "i20") {
document.getElementById('CarDetail').innerHTML = carDetails[2][0] +
"-" + carDetails[2][1] + "-" + carDetails[2][2];
}
else if (x == "i10") {
document.getElementById('CarDetail').innerHTML = carDetails[3][0] +
"_" + carDetails[3][1] + "-" + carDetails[3][2];
}
}

index.html

<html>

<head><script type="text/javascript" src="index.js"></script></head>

<body>

<label>Please Choose a Car to get its Details</label></br>

<select id="SelectCar">

<option value="Innova"> Innova</option>

<option value="Dzire">Dzire</option>

<option value="i20">i20</option>

<option value="i10">i10</option></select>

<button onclick="displayCarDetails()"> Get Data</button>

<p id="CarDetail"></p>

</body> </html>
3rd
index.js

function getAge() {

var x = document.getElementById('dob').value;

var d = new Date();

var dd = d.getFullYear();

var xx = x.substring(0, 4);

if (xx <= dd) {

var y = dd - xx;

document.getElementById('showresults').innerText = "You are " + y + "

year(s) old!!";

} else {

document.getElementById('showresults').innerText = "Wrong date!!";

index.html
<html>
<head><script src="index.js" type="text/javascript"></script></head>
<body>
<h2>JavaScript Objects</h2>
<label>Enter your DOB</label>
<form><input type="text" id="dob" name="dob"></form>
<button type="submit" onclick="getAge()"›submit</button>
<p id="showresults"></p>
</body>
</html>

4th

index.js
function SumOfSeries() {
let a = 0, b = 1;
let sum = 0;

while (a < 100) {


sum += a;
let temp = a + b;
a = b;
b = temp;
}

document.getElementById("result").innerText = sum;
}

You might also like