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

JavaScript Integer Input and Display

The document contains examples of JavaScript programs that accept integer inputs and display them, including functionality for displaying two integers and their sum. It also includes homework questions related to web page design elements and tasks for creating web pages to accept and display student and employee details, as well as performing addition operations on integer and float numbers. Each example is presented with HTML structure and JavaScript functions for handling user input and displaying results.
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)
3 views7 pages

JavaScript Integer Input and Display

The document contains examples of JavaScript programs that accept integer inputs and display them, including functionality for displaying two integers and their sum. It also includes homework questions related to web page design elements and tasks for creating web pages to accept and display student and employee details, as well as performing addition operations on integer and float numbers. Each example is presented with HTML structure and JavaScript functions for handling user input and displaying results.
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

Example10: Write a javascript program to accept an integer and display it.

Design

Program: [Link]
<!DOCTYPE html>
<html>
<head>
<title> Displaying an integer </title>
</head>
<body>
<label> Enter one integer</label>
<input type="text" id="textbox1"><br><br>
<input type="submit" value="Display" onclick="show()">
<p id="display" style="font-family:verdana; font-size:20px;"></p>
<script>
function show()
{
var a=[Link]
[Link]("display").innerHTML="Entered integer value is:"+a
}
</script>
</body>
</html>

Output:

Example11: Write a javascript program to accept two integers and display


them.
Design

Program: [Link]
<!DOCTYPE html>
<html>
<head>
<title> Displaying integers </title>
<style>
label{
font-family:arial black;
font-size:20;
}
</style>
</head>
<body>
<label> Enter first integer</label>
<input type="text" id="textbox1"><br><br>
<label> Enter second integer </label>
<input type="text" id="textbox2"><br><br>
<input type="submit" value="Display" onclick="show()">
<p id="display" style="font-family:verdana; font-size:20px;"></p>
<script>
function show()
{
var a=[Link]
var b=[Link]
[Link]("display").innerHTML="First integer number
is:"+a+"<br><br>"+"Second integer number is:"+b
}
</script>
</body>
</html>
Output:

Example12: Write javascript program to accept two integers and display its
sum.
Design

Program: [Link]
<!DOCTYPE html>
<html>
<head>
<title> Addition of two integers </title>
</head>
<body>
<label> Enter first integer: </label>
<input type="text" id="textbox1"><br><br>
<label> Enter second integer: </label>
<input type="text" id="textbox2"><br><br>
<label>Addition of two integers:</label>
<input type="text" id="textbox3" disabled="true"><br><br>
<input type="submit" value="Addition" onclick="addition()"><br><br>
<script>
function addition()
{
var a=parseInt([Link])
var b=parseInt([Link])
var c=a+b
[Link]("textbox3").value=c
}
</script>
</body>
</html>

Output
Homework:
Interview questions:
1) What is a label?

2) What is a textbox?

3) How to give style to label?

4) How to disable one textbox?

Task1: Design a web page to accept Student details and display them
Student Details: Student ID, Student Name , Student address, student course,
student email ID, student phone number

Task2: Design a web page to accept employee details and display them
Employee Details: Emp ID, Emp Name, Emp Salary
Task3: Design a web page to accept four integer numbers and perform
addition operation and display the result in textbox

Task4: Design a web page to accept three float numbers and perform addition
operation and display the result in textbox

You might also like