Question
Question 25. To attach an event handler to an event (such as a user clicking a button), you a. specify the action to be taken
Question 25. To attach an event handler to an event (such as a user clicking a button), you
a. specify the action to be taken
b. use a function declaration that is automatically called when an event occurs
c. specify the object and the event that triggers the event handler
d. can do any of the above
26. What will happen first as soon as the page that contains the following code loads?
window.onload = function() {
alert("Welcome to the Calculate Cost page!");
$("ship").onclick = shipCost(); };
a. An alert dialog box will display with the message "Welcome to the Calculate Cost page!".
b. A function with id = "ship" will execute automatically.
c. The function named shipCost() will execute automatically.
d. The function named shipCost() will execute when the user clicks on it.
27. Which of the following will create an event handler that is attached to the mouseout event for a textbox with id = "username" so that the users entry, formatted in all lowercase, will be displayed in an alert? Assume the following $ function has already been coded in the page:
var $ = function(id) {
return document.getElementById(id); };
a. var getUserName = function() {
alert("Your username is " + getUserName.toLowerCase()); };
window.onload = function() {
$("username").onmouseout = getUserName; };
b. var getUserName = function() {
var name = $("username").value;
alert("Your username is " + name.toLowerCase()); };
window.onload = function() {
$("username").onmouseout = getUserName; };
c. var getUserName = function() {
var name = $("id").value;
alert("Your username is " + name.toLowerCase()); };
window.onload = function() {
$("id").onmouseout = getUserName(); };
d. var getUserName = function() {
var name.toLowerCase() = $("username").value;
alert("Your username is " + name); };
window.onload = function() {
$("id").onmouseout = getUserName(); };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started