You are on page 1of 10

ITA ASSIGNMENT 1

MEENU MARIA GIBY

U18CO106

1.write a program to find maximum of 3 nosusing math object(use prompt box for each input).

<script>

var inputNumber;//the 3 input checker variable

var value;//this is the variable receiving each value

var arr = [];//this is like an array for storing the 3 inputs

inputNumber = 1;

while ( inputNumber <= 3 )

value = window.prompt( "Enter number " + inputNumber + " of 3:" , "" );

while(isNaN( value ))//isNaN() :a value is an illegal number (Not-a-Number).

value = window.prompt( "Enter number " + inputNumber + " of 3:" , "" );

arr[inputNumber] = value;

inputNumber = inputNumber + 1;

finalMax = Math.max(arr[1], arr[2], arr[3]);

document.write("<h1>The highest number is " + finalMax + "</h1>" );

</script>

o/p:
2.write a javascript to validate student MIS registration form for SVNIT students. If a blank field is left it should display
an error message.

<html>

<head>

<script>

function valid() {

var name =

document.forms["RegForm"]["Name"];

var what =

document.forms["RegForm"]["Subject"];

var password =

document.forms["RegForm"]["Password"];

if ((name.value =="")&&(password.value =="")){

window.alert("Please fill the form. All columns empty.");

name.focus(); password.focus(); what.focus();

return false;

if (name.value == "") {

window.alert("Please enter your username.");

name.focus();

return false;
}

if (password.value == "") {

window.alert("Please enter your password");

password.focus();

return false;

if (what.selectedIndex < 1) {

alert("Please enter your course.");

what.focus();

return false;

return true;

</script>

<style>

div {

box-sizing: border-box;

width: 100%;

border: 100px solid black;

float: left;

align-content: center;

align-items: center;

form {

margin: 0 auto;

width: 600px;

}
</style>

</head>

<body>

<h1 style="text-align: center;">MIS REGISTRATION FORM</h1>

<form name="RegForm" action="/submit.php"

onsubmit="return valid()" method="post">

<p>Username: <input type="text"size="65" name="Name" /></p>

<br />

<p>Password: <input type="text"size="65" name="Password" /></p>

<br />

<p> SELECT YOUR COURSE

<select type="text" value="" name="Subject">

<option>BTECH</option>

<option>MTECH</option>

<option>PHD</option>

</select>

</p>

<br />

<br />

<p>

<input type="submit"value="send" name="Submit" />

<input type="reset"value="Reset" name="Reset" />

</p>

</form>

</body>

</html>
3. make a simple interest Calculator using javascript. The result calculated should be displayed in a new window.

<html>

<head>

<title></title>

<script>

function calculate()

p = document.getElementById("p").value;

n = document.getElementById("n").value;

r = document.getElementById("r").value;

result = "The interest is " + (p*n*r/100);

var win = window.open();

win.document.write(result);
}

</script>

</head>

<body>

<h1>Simple Interest Calculation</h1>

Amount: <input id="p"><br/>

Rate: <input id="r"><br/>

No. of Years: <input id="n"><br/>

<button onclick="calculate()">Calculate</button>

<p id="result"></p>

</body>

</html>

4.create home page for SVNIT college displaying amenities of college in an automatic carousel using javascript.

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="ie=edge">


<title>Auto Play image Slider</title>

</head><body>

<div class="slider">

<div id="img">

<img src="e.jpg">

</div>

</div>

<script>

var images = ['a.jpg', 'b.jpg', 'c.jpg', 'd.jpg', 'e.jpg'];

var x = 0;

var imgs = document.getElementById('img');

setInterval(slider, 2000);

function slider() {

if (x < images.length) {

x = x + 1;

} else {

x = 1;

imgs.innerHTML = "<img src=" + images[x - 1] + ">";

} </script>

<style type="text/css">

.slider {

width: 90%;

height: 500px;

margin: 20px auto;

box-sizing: border-box;

overflow: hidden;

box-shadow: 5px 5px 10px grey;

} img {

width: 100%;

height: 100%;

animation: ani 2s linear;


}

@keyframes ani {

0% {

transform: scale(1.2);

10% {

transform: scale(1);

100% {

transform: scale(1);

</style>

</body></html>

5.create one form for taking input via checkbox from user for receiving updates via newsletter for events at
SVNIT.only if user selects to opt for newsletter, display options using checkbox for selecting from events suck as
annual fest, drishti events, student chapters,STTP,summer schools,talks ,conferences,workshops,courses through
NPTEL.Display the selecte choises in a new tab.

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Fifth Assignment</title>

</head>

<body>

<h1>Signup for our newsletter</h1>

<form onSubmit="handleSubmit()" id="form">


<div> <h2>Want to subscribe to our newsletter?</h2>

<br />

<input type="radio" name="opt" value="yes" /> Yes

<br />

<input type="radio" name="opt" value="no" /> No

<br />

</div> <div id="hiddenChoices">

<h2>Choose your interests:</h2>

<input type="checkbox" name="choices" value="Annual fest" /> Annual Fest

<br />

<input type="checkbox" name="choices" value="Drishti" /> Drishti

<br />

<input type="checkbox" name="choices" value="ACM" /> ACM

<br />

<input type="checkbox" name="choices" value="STTP" /> STTP

<br />

<input type="checkbox" name="choices" value="Workshops" /> Workshops

<br />

</div>

<br />

<button type="submit">Subscribe</button>

</form>

</body>

<script>

function handleSubmit() {

let form = document.forms['form'];

console.log(form['opt'].value);

let newWindow = window.open();

res = '<h1>Your responses:- </h1><br>';

if (form['opt'].value === 'yes') {

res += `<h2> Subscribe to newsletter :- ${form['opt'].value} </h2> <br>`;

res += '<h2> Your choices:- </h2><br>';

res += '<ul>';

document.getElementsByName('choices').forEach((checkbox) => {
if (checkbox.checked) {

res += `<li>${checkbox.value}</li><br>`;

});

res += '</ul>';

} else {

res += `<h2> Subscribe to newsletter :- ${form['opt'].value} </h2> <br>`;

} newWindow.document.write(res);

document.getElementById('hiddenChoices').style.display = 'none';

let opt_round_buttons = document.getElementsByName('opt');

opt_round_buttons.forEach((rb) =>

rb.addEventListener('change', () => {

console.log(rb.value);

if (rb.value == 'yes') {

document.getElementById('hiddenChoices').style.display = 'block';

} else {

document.getElementById('hiddenChoices').style.display = 'none';

})

);

</script> </html>

You might also like