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

Practical No 2

This document contains an HTML program that takes in three numeric variables as input and outputs the largest and smallest of the three. It also contains a function to output a loop of numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Practical No 2

This document contains an HTML program that takes in three numeric variables as input and outputs the largest and smallest of the three. It also contains a function to output a loop of numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Practical no 2

Program:

<html lang="en">

<head>
<title>Practical no 2</title>
</head>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bo
otstrap.min.css">
<style>
h1{
font-family:'Gill Sans', 'Gill Sans MT', Calibri,
'Trebuchet MS', sans-serif;
font-size: 34px;
}
label{
font-size: 24px;
}
input{
font-size: 18px;
}
</style>

<body>
<form name="prac" style="text-align: center; margin-top:
250px !important; border: 3px solid black; margin: 0px
600px; border-radius: 10px;">

<h1>Practical no 2</h1>
<div class="row">
<div class="col-6">
<label for="num1">First Variable</label>
<input type="text" name="num1">
</div>
<div class="col-6">
<label for="num2">Second Variable</label>
<input type="text" name="num2">
</div>
</div>

<label for="num3">Third Variable</label>


<input type="text" name="num3">
<br><br>
<input type="button" onclick="large()"
value="Largest">
<input type="button" onclick="small()"
value="Smallest" style="margin-left: 50px">
<input type="button" onclick="loop()" value="Loop
Numbers" style="margin-left: 50px">
<br><br>
<label for="result">Result: </label>
<input type="text" name="result" style="margin-left:
50px;">
<br><br>
<label for="result">Loop Result: </label>
<br>
<p id="para"></p>
</form>

<script type="text/javascript">
function loop(){
var var1 = parseInt(prac.num1.value);
for(i=0; i<var1; i++){
document.getElementById('para').innerHTML =
document.getElementById('para').innerHTML + " " + i
}
}
function large()
{
var var1 = parseInt(prac.num1.value);
var var2 = parseInt(prac.num2.value);
var var3 = parseInt(prac.num3.value);
var res;
if (var1 >= var2)
{
if (var1 >= var3)
{
res = var1;
}
else
{
res = var3;
}
}
else
{
if (var2 >= var3)
{
res = var2;
}
else
{
res = var3;
}
}
prac.result.value = res;
}
function small()
{
var var1 = parseInt(prac.num1.value);
var var2 = parseInt(prac.num2.value);
var var3 = parseInt(prac.num3.value);
var res;
if (var1 <= var2)
{
if (var1 <= var3)
{
res = var1;
}
else
{
res = var3;
}
}
else
{
if (var2 <= var3)
{
res = var2;
}
else
{
res = var3;
}
}
prac.result.value = res;
}
</script>
</body>

</html>

Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy