0% found this document useful (0 votes)
18 views7 pages

WT Week 5 H6

1. The document contains 6 problem statements for writing HTML and JavaScript programs. The problems include changing paragraph text when a button is clicked, turning a light on and off, finding the maximum of 3 numbers, calculating the sum of digits in a number, checking if a number is a palindrome, and checking if a number is prime. 2. Sample code is provided for each problem statement that demonstrates how to write the HTML and JavaScript code to solve each problem. The code includes using functions, buttons, images, and conditionals. 3. The output is displayed for users when running the code samples, such as displaying the maximum number, sum of digits, or whether the number is a palindrome or prime.

Uploaded by

designandeditors
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)
18 views7 pages

WT Week 5 H6

1. The document contains 6 problem statements for writing HTML and JavaScript programs. The problems include changing paragraph text when a button is clicked, turning a light on and off, finding the maximum of 3 numbers, calculating the sum of digits in a number, checking if a number is a palindrome, and checking if a number is prime. 2. Sample code is provided for each problem statement that demonstrates how to write the HTML and JavaScript code to solve each problem. The code includes using functions, buttons, images, and conditionals. 3. The output is displayed for users when running the code samples, such as displaying the maximum number, sum of digits, or whether the number is a palindrome or prime.

Uploaded by

designandeditors
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

WEB TECHNOLOGIES LAB

NAME: M NAGA SREEYA DATE: 13.10.2023


HTNO: 21R21A05H6
WEEK-5

Problem statements
1 Write an HTML program including any required Javascript , when the button named “CLICK
HERE” is clicked then Paragaraph content should be changed.

2 Write a Javascript program to turn on the light and turn off the light.

3 Write an HTML program including any required Javascript to find maximum of three numbers
using functions

4 Write an HTML program including any required Javascript to find sum of individual digits.

5 Write an HTML program including any required JavaScript that receives an integer in one text
field, and check whether the number is palindrome or not, when the button named
“palindrome” is clicked.

6 Write an HTML program including any required Javascript that receives an integer in one text
field, and check whether the number is prime or not, when the button named “Prime” is
clicked
1. Write an HTML program including any required Javascript , when the button named “CLICK HERE” is
clicked then Paragaraph content should be changed.
PROGRAM CODE:
<html>
<head><title>Paragraph</title></head>
<body>
<p id="abc">JavaScript is a lightweight interpreted programming language </p>
<input type="button" value="CLICK HERE" onclick="document.getElementById('abc').innerHTML ='It
can be used for both Client-side as well as Server-side developments'">
</body>
</html>
OUTPUT:
2.Write a Javascript program to turn on the light and turn off the light
PROGRAMCODE:
<html>
<head><title>Lights</title></head>
<body>
<img id="abc" src="https://www.livehome3d.com/assets/img/articles/comparinglightbulbtypes/
[email protected]" alt="Light" width="200" height"200"><br><br>
<input type="button" value="Light ON"
onclick="document.getElementById('abc').src='https://cdn.mos.cms.futurecdn.net/
HaPnm6P7TZhPQGGUxtDjAg-320-80.jpg'" width="200" height"200">
<input type="button" value="Light OFF"
onclick="document.getElementById('abc').src='https://www.livehome3d.com/assets/img/articles/
comparinglightbulbtypes/[email protected]'">
</body>
</html>
OUTPUT:

3. Write an HTML program including any required Javascript to find maximum of three numbers using
functions
PROGRAM CODE:
<html>
<head><title>Max</title></head>
<body>
<h2>Maximum of three numbers</h2>
<input type="button" value="Result" onclick="myfun()">
<p id="a"></p>
<script>
function myfun()
{
var a=prompt("Enter a value");
var b=prompt("Enter b value");
var c=prompt("Enter c value");
if(a>b && a>c){
document.getElementById('a').innerHTML="Maximum of three numbers is "+a;
}
else if(b>a && b>c){
document.getElementById('a').innerHTML="Maximum of three numbers is "+b;
}
else {
document.getElementById('a').innerHTML="Maximum of three numbers is "+c;
}
}
</script>
</body>
</html>
OUTPUT:

4.Write an HTML program including any required Javascript to find sum of individual digits.
PROGRAM CODE:
<html>
<head><title>Sum of digits</title></head>
<body>
<h3>Sum of digits</h3>
<input type="button" value="Result" onclick="myfunction()">
<p id="a"></p>
<script>
function myfunction()
{
var n=prompt("Enter n value");
var sum=0,rem;
while(n>0)
{
rem=n%10;
sum=sum+rem;
n=parseInt(n/10);
}
document.getElementById("a").innerHTML="Sum of digits is "+ sum;
}
</script>
</body>
</html>

OUTPUT:
5. Write an HTML program including any required JavaScript that receives an integer in one text field,
and check whether the number is palindrome or not, when the button named “palindrome” is clicked
PROGRAM CODE:
<html>
<head><title>Palindrome</title></head>
<body>
<h3>Palindrome</h3>
<input type="button" value="Palindrome" onclick="myfunction()">
<p id="a"></p>
<script>
function myfunction()
{
var n=prompt("Enter n value");
var sum=0,rev;
temp=n;
while(n>0)
{
rev=n%10;
sum=(sum*10)+rev;
n=parseInt(n/10);
}
if(temp==sum)
document.getElementById("a").innerHTML="It is a palindrome";
else
document.getElementById("a").innerHTML="It is not a palindrome";
}
</script>
</body>
</html>
OUTPUT:
6.Write an HTML program including any required Javascript that receives an integer in one text field, and
check whether the number is prime or not, when the button named “Prime” is clicked
PROGRAM CODE:
<html>
<head><title>Prime</title></head>
<body>
<h3>Prime Number</h3>
<input type="button" value="Prime or not" onclick="myfun()">
<p id="a"></p>
<script>
function myfun()
{
var n=prompt("Enter n value");
var fact=1,i;
for(i=0;i<=n;i++)
{
if(n%i==0)
fact=fact+1;
}
if(fact==2)
document.getElementById("a").innerHTML="It is a prime number";
else
document.getElementById("a").innerHTML="It is not a prime number";
}
</script>
</body>
</html>

OUTPUT:

You might also like