Você está na página 1de 7

1) Design a simple application in JavaScript to find the biggest of three numbers?

<html>
</head>
<script type="text/javascript">
function f1()
{
var a;
var b;
var c;
a=parseInt(n1.value);
b=parseInt(n2.value);
c=parseInt(n3.value);
if((a>b)&&(a>c))
{
alert(a+" is the biggest");
}
else if ((b>a)&&(b>c))
{
alert(b + " is the biggest");
}
else
{
alert(c + " is the biggest");
}
}
</script>
</head>
<body>
<table border="1" bgcolor="green">
<tr>
<td> Input first number</td>
<td> <input type="text"
name="n1"></td>
</tr>
<tr>
<td> Input Second number</td>
<td> <input type="text" name="n2">
</td>
</tr>
<td> Input 3rd Number </td>
<td> <input type="text" name="n3">
</td>
</tr>
</table>
<input type="button" value="biggest"
onclick="f1()">
</body>
</html>

Student Name: Mohamed Hassan Batch No: 2k8/DSE/23 Student Id: MIDSE 552
2

Q2) Design a simple application in JavaScript to greet the user in accordance with the system
time when the page is displayed. If the time is between 0-12 “Good morning”, 12-15 “Good
Afternoon”, 15-20 “Good Evening”, 20-25 “Good Night”?

<html>
<head>
</head>
<body>
<script type="text/javascript">

var d = new Date();


var hrs=d.getHours();

if((hrs>=0)&&(hrs<12))
{
alert("Good morning");
}
else if((hrs>=12)&&(hrs<15))
{
alert("Good afternoon");
}
else
if((hrs>=15)&&(hrs<20))
{
alert("Good Evening");
}
else
{
alert("Good Night");
}

</script>

</body>
</html>

Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552
3

Q3) Design a simple application in JavaScript to perform the sales transaction for ABC
company. The page should contain a combo box which displays minimum of 4 items, a text box
to display the item name, another textbox to display the price, another text box to display the
Quantity, and a text box to display the total amount. When the user selects a item code from the
combo box the corresponding item name should be displayed in the item name text box, as well
as the price of the item in the price text box. On users input for the quantity purchased the total
should be calculated and displayed in the total amount text box?

Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552
4

Q4) Design a simple JavaScript to check whether a given value is a string or a number?

<html>
<head>
<script type="text/javascript">
function f()
{
var n;
n=(a.value);
if(n!="")
{
if((n>=0)&&(n<=99999999999999999))
{
alert(n+" is a number");
}
else
{
alert(n+" , is a string or
character");
}
}
else
{
alert("enter number or string or
character");
}
}
</script>
</head>
<body>

Enter a number or a string:


<input type="text" name="a">

<br>
<input type="button" value="check"
onclick="f()">
</body >
</html>

Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552
5

Q5) Design a simple application in JavaScript to demonstrate the submission of a persons


resume.

Firs name

Second name

Gender

Qualification Combo box values are

Address O/L

Mobile Number O/L + Diploma

A Level
Submit
A Level + Diploma

On pressing the submit button, the program should check whether all the fields are entered with
values, else display appropriate message box to the user. If all fields are supplied with values,
the details entered should be displayed in a new document in the given format

Applicant Name

Gender

Qualification

Address

Mobile Number

Gender should be displayed as Male/Female not as M/f. First the name and last Name should be
combined together.

Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552
6

Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552
7

Q6) Design a simple application in JavaScript to demonstrate a login page. If the user has
provided a valid user name and password as in the program load a new page called main.html,
else display appropriate error messages?
<html>
<head>
<script type="text/javascript">
function log()
{
var uname;
var upassword;
var duname="hassan";
var dpassword="123";

uname=txt1.value;
upassword=txt2.value;
if(uname==duname)
{
if(upassword==dpassword)
{
alert("welcome "+uname);
document.open("main.html");

}
else
{
alert("invalid password");
}

}
else
{
alert("Invalid user name");
}
}

</script>
</head>
<body>
<table bgcolor="aqua">
<tr>
<td> User Name</td>
<td> <input type="text"
name="txt1"></td>
</tr>
<tr>
<td>Password </td>
<td> <input type="text"
name="txt2"></td>
</tr>
<tr>
<td><input type="button" value="login"
onclick="log()" > </td>
<td> <input type="button"
value="cancel"></td>
</tr>
</table>
</body>
</html>

Student Name: Mohamed Hassan Batch No: DSE/23 Student Id: MIDSE 552

Você também pode gostar