191202C0058 Exp7

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

DEPARTMENT OF INFORMATION TECHNOLOGY

Subject: Operating Systems Subject Code: 22519


Semester: 5th Course: IF5IC
Laboratory No: L003C Name of Subject Teacher: Yogita Jore
Name of Student: Indu Medisetti Roll Id: 19202C0058

Experiment No: 7
Aim Create a webpage to implement form events. Part 1

Practical Significance:
A JavaScript executes in response to an event that occurs while a form is displayed on the
screen. An event is something the user does to the form, such as clicking a button, selecting a
radio button, or moving the cursor away from an element on the form. The browser also fires
events when the page finishes loading from the server.

Practical related questions:


Practical related questions:

1) Explain Java Intrinsic functions.

ANS: - An intrinsic function is a function that performs a mathematical,


character, or logical operation, and thereby allows you to make reference to a
data item whose value is derived automatically during execution.

2) Write the events which are used by checkbox and buttons.


ANS: - There are two events that you can attach to the checkbox to be fired
once the checkbox value has been changed they are the onclick and the
onchange events.

The default event for the Page object is Load event. Similarly, every control
has a default event. For example, default event for the button control is the
Click event.

3) Explain the use of with keyword in javascript.

192020058
ANS: - The 'with' statement adds the given object to the head of this scope
chain during the evaluation of its statement body. If an unqualified name used
in the body matches a property in the scope chain, then the name is bound to
the property and the object containing the property. Otherwise a
ReferenceError is thrown.

4) What is the use of oncontextmenu event?

ANS: - The oncontextmenu event occurs when the user right-clicks on an


element to open the context menu

Exercise:

Write a program for changing the option list dynamically.

Code

<html>
<body>
<html>
<script type="text/javascript">
function modifyList(x)
{
with(document.forms.myform)
{
if(x ==1)
{
optionList[0].text="Kiwi";
optionList[0].value=1;
optionList[1].text="Pine-Apple ";
optionList[1].value=2;
optionList[2].text="Apple";
optionList[2].value=3;
}
if(x ==2)
{
optionList[0].text="Tomato";
optionList[0].value=1;
optionList[1].text="Onion ";
optionList[1].value=2;
optionList[2].text="Cabbage ";
optionList[2].value=3;
}
}
}

192020058
Client-Side Scripting (Semester V)
57
</script>
</head>
</body>
<form name="myform" action=" " method="post">
<select name="optionList" size="3">
<option value=1>Kiwi
<option value=1>Pine-Apple
<option value=1>Apple
</select>
<br>
<input type="radio" name="grp1" value=1 checked="true"
onclick="modifyList(this.value)"> Fruits
<input type="radio" name="grp1" value=2 onclick="modifyList(this.value)">
Vegitables
</form>
</body>
</html>
Output: -

Develop a program for as we enter the firstname and lastname , email is


automatically generated.

Code: -

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Get Email ID</button><p
id="demo"></p><script>
function myFunction() {

192020058
var fname = prompt("Please enter your name");
var lname = prompt("Please enter your name");
document.getElementById("demo").innerHTML =
"Your Email Id is " + fname + lname +"@gmail.com";
}
</script></body>
</html>

Output : -

Conclusion:
Hence, we learnt to create a webpage to implement form event like option list.

Marks Obtained Dated Signature of Teacher


Process Related Product Total
(15) Related (50)
(35)

192020058

You might also like