McGraw-Hill OnlineMcGraw-Hill Higher EducationLearning Center
Student Center | Instructor Center | Information Center | Home
Sample Code
Multiple Choice Quiz
True or False
E-Lectures
Feedback
Help Center


Programming the Web Using XHTML and JavaScript
Larry Randles Lagerstrom

Forms and the Interactive Surfer

Multiple Choice Quiz



1

Which element creates a text field named boxo that can hold 10 characters?
A)<input type="textfield" name="boxo" width="10">
B)<input type="textbox" name="boxo" size="10">
C)<input type="textarea" name="boxo" size="10">
D)none of the above
2

Which element creates a text field named boxo that can hold 10 characters?
A)<input type="textfield" name="boxo" width="10">
B)<input type="text" id="boxo" size="10">
C)<input type="textarea" name="boxo" width="10">
D)none of the above
3

Assume a form named f1 has two text fields named b1 and b2. Given this function definition:
function greet(box1, box2){
box2.value = box1.value
}
Which is the correct function call to retrieve the value from b1 and display it in b2?
A)greet(document.f1.b1.value, document.g1.b2.value)
B)greet(document.f1.b2, document.g1.b1)
C)greet(document.f1.b2.value, document.g1.b1.value)
D)none of the above
4

Assume a form named f1 has two text fields named b1(whose value is "alpha") and b2 (whose value is "whiskey"). After this script executes:
<script>
function greet(value1, value2){
value2 = value1
}
greet(f1.b1.value, f1.b2.value)
</script>
Which value will be displayed in fields b1 and b2?
A)alpha, alpha
B)alpha, whiskey
C)whiskey, alpha
D)whiskey, whiskey
5

Assume a form named f1 has two text fields named b1(whose value is "alpha") and b2 (whose value is "whiskey"). After this script executes:
<script>
function greet(box1, box2){
box2.value = box1.value
}
greet(f1.b1, f1.b2)
</script>
Which value will be displayed in fields b1 and b2?
A)alpha, alpha
B)alpha, whiskey
C)whiskey, alpha
D)whiskey, whiskey
6

Consider this script:
<script>
var x = //details omitted…
function blackBox(p){ //details omitted…. }
alert(x)
blackBox(x)
alert(x)
</script>
Assuming x is passed by copy, which statement is true?
A)the two alerts display the same value
B)the two alerts may display the same or different values
C)the two alerts display different values
D)x cannot be passed by copy
7

Consider this script:
<script>
var x = //details omitted…
function blackBox(p){ //details omitted…. }
alert(x)
blackBox(x)
alert(x)
</script>
Assuming x is passed by address, which statement is true?
A)the two alerts display the same value
B)the two alerts may display the same or different values
C)the two alerts display different values
D)x cannot be passed by address
8

Assume a form named f1 has two text fields named b1(whose value is "alpha") and b2 (whose value is "whiskey"). Consider this script:
<script>
function greet(f){
f.b2.value = f.b1.value
}
greet(document.f)
</script>
Which statement is true?
A)f is passed by copy
B)f is passed by address
C)the function call never gets executed
D)the browser does not recognize the function declaration in a script element
9

Which event handler would you use when a field loses focus
A)onfocus
B)onlostfocus
C)onblur
D)onblinkenlights
10

Which event occurs when the user enters text in a field and hits the Enter key?
A)focus
B)blur
C)change
D)signal




McGraw-Hill/Irwin