Programming | JavaScript, Ajax » Instructors Materials to accompany JavaScript, test your knowledge

Datasheet

Year, pagecount:1999, 26 page(s)

Language:English

Downloads:10

Uploaded:March 28, 2013

Size:121 KB

Institution:
-

Comments:

Attachment:-

Download in PDF:Please log in!



Comments

No comments yet. You can be the first!

Content extract

Instructor’s Materials to accompany JAVASCRIPT PROJECT TWO CREATING POP-UP WINDOWS, ADDING SCROLLING MESSAGES, AND VALIDATING FORMS LESSON PLAN OBJECTIVES Students will have mastered the material in this project when they can:  Explain the four basic components of a  Validate data entry using a nested scrolling message IfElse statement  Write a user-defined function to display  Describe the parseInt(), parseFloat(), and a scrolling message in a form text box isNaN() built-in functions  Describe the If statement  Describe the math pow() method  Define conditionals and discuss the  Write a user-defined function to format conditional operands output in currency format  Define recursion  Discuss For and While loops  Describe the focus() method  Use the open() method to display  Write a user-defined function to another Web page in a pop-up window calculate mortgage payments  Use the lastModified property to display the date a Web page was last

modified PROJECT OVERVIEW In this project, students will create a Web page that will allow Home Finders Nationwide Realty customers to calculate the amount of their monthly mortgage payment, based on the amount of mortgage, interest rate, and the number of years. The students will learn how to add a scrolling message, which will introduce them to the substring() method and the If statement. Students will learn how to use JavaScript to validate forms. The validation routine introduces IfElse statements, the parseInt(), parseFloat(), and isNaN() built-in functions, as well as using the pow() method. In addition students write functions to calculate and display the resulting monthly payment amount using the currency format. Finally students learn how to add a pop-up window to display information on using the mortgage payment calculator. J 2.1 J 2.2 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms LESSON PLAN Project Outline  It Figures! Mortgage

Sites Are Keys to Home Ownership I. Introduction II. Project Two Home Finders Nationwide Realty Page Teacher Notes and Activities J 2.2 Ask students how many have used the Internet to purchase something. Discuss with students the idea of looking for a house online. Ask students to discuss the applying for loans online, what do they think are important issues? Discuss the ramifications of online loan processing on banks. Discuss other legal aspects and how borrowers can be "ripped off." Have students check out the MSN HomeAdvisor Web site (homeadvisor.msncom) Have students look for other online lenders and realtors. J 2.4 Review the concepts learned in Project 1. Emphasize the relationship between JavaScript and HTML. Ask students to discuss the difference between the userdefined function and built-in functions in Project 1. Inform students that this project develops more user-defined functions and relies on more built-in functions. Briefly introduce the If and IfElse

statement concepts. Ask students to think of reasons to test values that might be entered. Ask students if they have encountered Web sites that use pop-up windows. Ask them the reasons for the new windows. J 2.4 Discuss the case perspective. Use Figures 21a through 2-1c to discuss the needs, data validation, and calculations that are identified. Briefly discuss the formula for calculating the monthly payment, and note that the formula will be discussed in more detail later. JavaScript Instructor’s Materials J 2.3 Project Outline Page Teacher Notes and Activities J 2.6 If necessary, review the steps to a file in Notepad. Use Figure 2-2 to discuss the home.htm file III. Inserting a scrolling message on a Web page J 2.7 Discuss Microsofts Marquee HTML tag and explain that it is not available in Netscape Navigator. Explain where a scrolling message may display. Discuss the four components of a scrolling message, defining each term: the display object, the message, the

position, and the delay. Warn students about using large messages. Explain that this message will be displayed in a form text box. Use Figure 2-3 to explain the relationship between the form and the text box. Discuss the More About Scrolling Messages box and The Marquee Tag boxes. A. Creating a form text J 2.8 Explain that the Home Finders Nationwide Realty Web page uses a table to present the graphics, links, and the scrolling message. Use Figures 2-4 and 2-5 to describe how to create a form text box to display a scrolling message. Ask students to explain the FORM and INPUT HTML tags. J 2.10 Explain the purpose of the function scrollingMsg(). Explain the need for the three variables. Explain the assignment statement that places the message in the text box. Use Figure 2-6 to explain the relationship between the form text box object and how the assignment statement places the message in the text box. Use Figures 2-7 through 2-9 to explain the beginning steps and statement in

Starting Notepad and opening the home.htm file box to display a scrolling message B. Creating a userdefined function for a scrolling message J 2.4 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms Project Outline Page Teacher Notes and Activities creating the scrollingMsg() user-defined function. J 2.12 Use Table 2-1 to discuss the various ways to increment a value in a variable. Explain the most common way is the third example in the table. IV. Entering an If statement J 2.13 Explain the need for the If statement in the function. Use Figure 2-10 and Table 2-2 to explain how the If statement works. Define condition. Discuss the More About The If Statement and Conditional Operators boxes. Use Table 2-3 to explain the conditional operands. Use Figure 2-11 to explain how the If statement will be used in the scrollingMsg() function. Use Figures 2-12 and 2-13 to explain entering an If statement. V. Using the setTimeout() method to create a

recursive function call J 2.15 Review the setTimeout() method from Project 1. Define recursion Explain the problems that may occur with recursive calls. Use Figure 214 to add the setTimeout() method to the function for a recursive call. Discuss the More About Recursion box. Adding an event handler J 2.16 Use Table 2-4 to explain the general form of an HTML tag and placement of an event handler. Use Table 2-5 to explain the different event handlers and to which type of object they may be associated. Use Figure 2-15 to describe entering the event handler to call the scrollingMsg() user-defined function. Discuss the More About Event Handlers box. VI. Saving the HTML file and testing the Web page J 2.18 Review the steps to save and test the Web page. Tell students to save the project as C. Incrementing the position locator variable JavaScript Instructor’s Materials J 2.5 Project Outline Page Teacher Notes and Activities homefinders.htm Remind them of the importance of

saving frequently. Figure 2-16 shows the completed Web page so far with a scrolling message. Explain that if the Web page does not work, students need to check their work against Figures 2-7 through 2-15. VII. The mortgage payment calculator form J 2.19 Use Figure 2-17 to explain the placement and layout of the mortgage calculator form. Explain how the text boxes are used to assign the data to the objects. Use Table 2-6 to explain the general form of the assignment statement. J 2.20 Review the HTML anchor tag and how it works with target links. Explain that an event handler needs to be associated with the HTML tag. Use Figures 2-18 and 2-19 to insert the onclick event handler in the anchor tag. VIII. Writing the doMort() user-defined function J 2.21 Explain the statements for the doMort() function as shown in Table 2-7. Use Table 2-8 to explain the purpose of the focus() method to define the set focus concept. Use Figure 220 to enter the doMort() function Saving and testing

the J 2.22 Review the steps to save and test the Web page. Use Figure 2-21 to explain the appearance of the Web page at this point. Tell students to check their statement against Figures 2-18 through 2-20 if they encountered errors. J 2.23 Discuss the importance of form validation. Ask students to think of the kind of errors that may be generated if invalid data are entered. Inserting an event handler in an anchor tag Web page IX. Validating the mortgage payment calculator form J 2.6 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms Project Outline Page Teacher Notes and Activities Ask students to think of the different types of invalid data that may be entered. Discuss the More About Validation box. A. Validating data using J 2.23 Explain the IfElse programming construct. Use Figure 2-22 to explain how the IfElse is used in validating data entry. Use Figure 223 to explain how the IfElse must be nested to validate the data in this Web

page because of the nature of event driven programming. Use Figure 2-24 to explain how to construct the nested IfElse statement and the importance of keeping blocks of code together. J 2.25 Use Table 2-9 to explain the various built-in functions that are needed to validate data entry items. Use Figure 2-25 to explain the relationship between the form object and how the values are passed to the function. Use Table 2-10 to explain the code used to pass the values and validate the data. Discuss the More About Validating Forms and The parseInt() Function boxes. Use Figure 2-26 to enter the validation code for the mortgage amount. Use Table 2-11 to explain the code used to validate the mortgage interest rate. Discuss the More About The parseFloat() Function and The isNaN() Function boxes. Use Figure 2-27 to enter the validation code for the interest rate. Use Table 2-12 to explain the code in validating the number of years the load is taken and Figure 2-28 to enter the validation of the

number of years data entry. Indicate the importance of the last braces the IfElse statement B. Validating data criteria using built-in functions JavaScript Instructor’s Materials J 2.7 Project Outline Page Teacher Notes and Activities shown in Table 2-12 lines 49 through 52. Emphasize that processing will stay in this function until all the data is validated. C. Adding an event J 2.29 Explain the association of the Calc() function to the event handler. Use Figure 2-29 to enter the onclick event handler to call the Calc() function. J 2.30 Review the steps to save and test the Web page. Have students use the data in Table 2-13 to test the validation function. The blanks indicate the student should leave the text box blank. Use Figure 2-30 to indicate how the page should appear when the last data item in the table is tested. Tell students to check their code against Figures 2-26 through 2-29. J 2.32 Discuss how the Calc() function must pass the data to another function,

Monthly(). Describe the parameters, and indicate these are the values needed to execute the payment expression discussed on page J 2.6 Use Figures 2-31 and 2-32 to enter the call to the monthly() user-defined function and pass the values. J 2.33 Discuss the code in Table 2-14. Point out the relationship of what is passed in the previous statement in Figure 2-32 and how the data is used in the monthly() function. Discuss the More About Math Object Methods. Explain the Math.pow() method using Table 2-15 Use Figure 2-33 to enter the monthly() function. Save and test the newly entered function. The result displays as shown in Figure 2-34. Tell handler to call a function D. Saving and testing the Web page X. Determining the monthly payment Creating the monthly() function students to check their code against Figures 2- J 2.8 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms Project Outline Page Teacher Notes and Activities 31 through 2-33. XI.

Formatting the monthly payment output as currency J 2.36 Ask the students what they think of the appearance of the monthly payment. Discuss the need for formatting output results for readability. Discuss the five steps the formatDollar() function will follow to format the output. A. Using the indexOf() J 2.36 Use Table 2-16 and Figure 2-35 to discuss the general form of the indexOf() method and how it works. Explain the purpose of the indexOf() in the dollarFormat() function. Discuss the More About The indexOf() Method box. J 2.37 Discuss the code in Table 2-17. Use Figure 236 to enter the beginning of the dollarFormat() function. J 2.38 Define loop. Discuss the need for a loop in the dollarFormat() function. Use Figure 2-37 to illustrate For and While loops. Use Tables 218 and 2-19 to explain the For loop and the While loop. J 2.39 Explain the code in Table 2-20 and how it extracts the dollars portion of the result and uses the While loop to determine where to place commas.

Use Figure 2-38 to enter the code that extracts the dollar portion and inserts the commas J 2.40 Use Table 2-21 to describe how to extract the value from the right of the decimal point. Explain how the value is treated if no decimal amount exists. Use Figure 2-39 to enter the method B. Determining the dollars portion C. Using For loops and While loops D. Extracting the dollars portion and inserting commas E. Extracting the cents portion and define the decimal amount code to extract the cents portion and define JavaScript Instructor’s Materials J 2.9 Project Outline Page Teacher Notes and Activities the decimal amount. F. Reconstructing the J 2.42 Use Table 2-22 to explain the code that reconstructs the dollars and cents portion of the output. Use Figure 2-40 to describe entering the code to reconstruct the formatted output and return the formatted value. J 2.43 Use Figures 2-41 and 2-42 to enter the code to pass the monthly payment value to the dollarFormat()

function. Review the five steps to save and test the Web page. Use Figure 243 to describe how the Web page displays Tell students to check their code against Figure 2-36 through 2-42. J 2.45 Define pop-up window. Have students describe Web pages they have encountered that used a pop-up window. Use Table 2-23 to explain the general form of the statement. Use Table 2-24 to explain the attributes that are used with the open() method. Discuss the statement needed to display the notice.htm file included in this project. Discuss the More About Creating Pop-up Windows box. Use Figures 2-44 and 2-45 to enter the open() method. Use Figure 2-46 to discuss the contents of the notice.htm file J 2.47 Review how the data last modified was used in the Fun with Phonics project. Use Figure 247 to explain the steps to add the date last modified on the Home Finders Nationwide Realty Web page. Point out to the students that the long document.write() statement is one line and should wordwrap in the

Notepad formatted output and returning the formatted value G. Passing the monthly payment value to the dollarFormat() function XII. Adding a pop-up window A. Adding the date last modified editor. J 2.10 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms J 2.48 Using Figure 2-48, review the five steps to save and test the Web page. XIII. Printing the HTML file using Notepad J 2.48 Review the steps to print the HTML file using Notepad. Use Figure 2-49 to describe the finished HTML file. XIV. Project summary J 2.50 Briefly review the material presented in this project. J 2.50 Encourage students to use this section in preparing for tests and quizzes. J 2.51 These exercises test students on their mastery of the material presented in this project. Exercises 1 through 4 can be reviewed and assigned at this time. J 2.54 These exercises ask students to use JavaScript Help to find out more about working with JavaScript. Exercises 1 and 2 can

be reviewed and assigned at this time. J 2.55 This exercise gives students a chance to apply their knowledge to a Web page document on the JavaScript Data Disk. Exercise 1 can be reviewed and assigned at this time. J 2.56 These exercises provide students with practice in using the skills developed in this project. Exercises 1 through 3 can be reviewed and assigned at this time. B. Saving and testing the finished Web page XV. What you should know XVI. Test your knowledge XVII. Use Help XVIII. Apply your knowledge XIX. In the lab Instructor’s Materials to accompany JAVASCRIPT PROJECT TWO CREATING POP-UP WINDOWS, ADDING SCROLLING MESSAGES, AND VALIDATING FORMS ANSWER MANUAL TEST YOUR KNOWLEDGE 1 True/False 1. 2. 2 3. 4. T F 5. 6. T F 7. 8. T T 9. 10. F T 3. 4. c d 5. 6. a b 7. 8. a b 9. 10. a d Multiple Choice 1. 2. 3 F T c a Understanding Event Handlers Object Event Handler button onclick document onload, onunload form onsubmit, onreset

hyperlink onclick, onmouseover, onmouseout image onload, onabort input box onblur, onchange, onfocus submit button onclick window onload, onunload, onblur, onfocus J 2.11 J 2.12 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms 4 Understanding Code Statements 1. 2. 3. 4. document.Form1Emailfocus() TempEmail = document.Form1Emailvalue TempBillingHours = parseFloat(document.Form1BillingHoursvalue) var tempString = "Test#12,Fall1999" var decipos = tempString.indexOf(",") var tempTest = tempString.substring(0,decipos) var tempDate = tempString.substring(decipos+1,16) 5. var area = pow(s, 2) var area = pi * pow(r, 2) USE HELP 1 Exploring Online Documentation 1. onabort: Executes JavaScript code when an abort event occurs; that is, when the user aborts the loading of an image (for example by clicking a link or clicking the Stop button). onchange: Executes JavaScript code when a change event occurs; that is, when a

Select, Text, or Text area field loses focus and its value has been modified. onkeydown: Executes JavaScript code when a KeyDown event occurs; that is, when the user presses a key. onmouseover: Executes JavaScript code when a MouseOver event occurs; that is, once each time the mouse pointer moves over an object or area from outside that object or area. 2 a. Typically, the object on which an event occurs handles the event. For example, when the user clicks a button, it is often the buttons event handler that handles the event. Sometimes you may want the window or document object to handle certain types of events instead of leaving them for the individual parts of the document. For example, you may want the document object to handle all MouseDown events no matter where they occur in the document. In Navigator 4.0, JavaScripts event capturing model allows you to define methods that capture and handle events before they reach their intended target. To accomplish this, the window, document,

and layer objects use these event-specific methods: capture events captures events of the specified type; release events ignores the capturing of events of JavaScript Instructor’s Materials J 2.13 the specified type; route event routes the captured event to a specified object; handle event handles the captured event (not a method of layer). b. Briefly, the steps for setting up event capturing are: (1) Set up the window to capture all Click events; (2) Define a function that handles the event; and (3) Register the function as the windows event handler for that event. 3 a. There are several ways of selecting substrings in JavaScript, including substring(), substr(), slice(), and the regexp functions. In JavaScript 10 and 11, substring() exists as the only simple way to select parts of a larger string. For example, to select the string press from Expression, use "Expression".substring(2,7) The first parameter to the function is the character index at which to start,

while the second parameter is the character index at which to end (non-inclusive): substring(2,7) includes the indices 2, 3, 4, 5, and 6. In JavaScript 1.2, substr(), slice(), and the regexp functions also can be used to dissect strings. The substr() behaves in the same fashion that Perls substr does, where the first parameter indicates the character index at which to start, while the second parameter indicates the length of the substring. To perform the same task as in the previous example, "Expression".substr(2,5) can be used Remember, 2 is the start point and 5 is the length of the resulting substring. When used on strings, slice() behaves very similarly to the substring() function. It is, however, a much more powerful tool, being able to operate on any type of array, and not only on strings. slice() also makes use of negative offsets to refer to a position taken from the end of the string rather than the beginning. "Expression"slice(2,-3) will return the

substring found between the second letter and the letter third from the end, returning press once more. The final, and most versatile, method for dealing with substrings is through the regular expression functions in JavaScript 1.2 Once again, demonstrating with the same example, the substring "press" is obtained from the string "Expression": write("Expression".match(/press/)); While this example is trivial, the regexp documentation is quite complete, providing more complex examples of the RegExp object and its related functions. b. Use Mathround() to multiply the number by ten times the number of decimal places you want to round off by, then divide by that number. For example: var pi = "3.1415926535"; // Round to tenths: pi = Math.round(pi*10)/10; // Round to hundredths pi = Math.round(pi*100)/100; J 2.14 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms // etc. c. It is important to note that the third

parameter to the windowopen() function can contain no white space: myWindow = window.open("http://wwwnetscapecom", "myWindowName", toolbar=yes, location=yes, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes, height=400, width=600"); d. Using Navigator 2x and 3x: <BODY onBlur="selffocus();"> Using a Communicator 4.x signed script: window.alwaysRaised = true; // Sets window to always on top window.alwaysLowered = true; // Anchors window to desktop e. This is only possible using Communicator 4x, and is documented in Whats New in JavaScript 1.2: windowReference = window.open("documenthtml", "windowName", "screenX=20, screenY=30") f. The "close window" alert will not appear if: The window you are trying to close programmatically was opened programmatically by your script or your scripts document, or the window you are trying to close is the first document loaded in that window (for

example, it was created by a link with a previously-unused target, or all documents have been loaded in the window using location.replace())Using Navigator version 4 or later, a signed script with Universal Browser Write privileges can close any window. 2 Exploring Links to Other JavaScript Sites 1. 2. 3. 4. 5. Students should submit a printout of the Marquee tag section. Students should submit a printout of the IfElse section. Students should submit a printout of the While statement section. Students should submit a printout of the Math.pow() object section Students should submit printouts of the isNaN(), parseInt(), and parseFloat() built-in function sections. 6. Students should submit a printout of the Form section 7. Students should submit printouts of the If-Then and While Loops and Text methods sections. JavaScript Instructor’s Materials J 2.15 APPLY YOUR KNOWLEDGE 1 Validating a Simple Registration Form 7. The completed project for this assignment is supplied in the

Instructor’s Lab Solutions section on the Instructor’s Resource Kit CD-ROM as the midwestrestsolution.htm file Students should submit a printout of the Web page and the HTML file. IN THE LAB 1 Calculating the Wind Chill Factor for a Ski Resort 10. The completed project for this assignment is supplied in the Instructor’s Lab Solutions section on the Instructor’s Resource Kit CD-ROM as the pinepeakssolution.htm file Students should submit a printout of the Web page and the HTML file. 2 Calculating a Percentage and Formatting the Result as a Percentage 8. The completed project for this assignment is supplied in the Instructor’s Lab Solutions section on the Instructor’s Resource Kit CD-ROM as the nutritionfactssolution.htm file Students should submit a printout of the Web page and the HTML file. 3 Calculating Retirement Savings 9. The completed project for this assignment is supplied in the Instructor’s Lab Solutions section on the Instructor’s Resource Kit CD-ROM as

the tristarsolution.htm file Students should submit a printout of the Web page and the HTML file. Instructor’s Materials to accompany JAVASCRIPT PROJECT TWO CREATING POP-UP WINDOWS, ADDING SCROLLING MESSAGES, AND VALIDATING FORMS TEST BANK  Test Bank Answers are on page J 2.23 Multiple Choice 156. The display object component of scrolling message can be either a. a form text box or the status bar b. a form text box or an HTML table cell c. the Windows task bar or title bar d. an INPUT() prompt or ALERT() message dialog box 157. Which of the following is not one of the four basic components of a scrolling message? a. text box b. message c. position d. delay 158. In which location do most Web developers recommend placing scrolling messages? a. on the windows task bar b. on the browsers status bar c. on the page in a text box d. in the browsers title bar 159. Which attribute(s) of the FORM and INPUT tags become the properties of the created object? a. value b.

value and name c. name d. name and type J 2.16 JavaScript Instructor’s Materials J 2.17 160. Which increment expression is the one most commonly used by programmers and Web developers? a. variable-b variable (variable ++ 1) c. variable++ d. variable = variable + 1 161. A condition is a. any expression that evaluates to True or False b. a built-in function that assigns a Boolean value to a variable c. a formula that is executed for a result d. an operand that indicates both conditions are True or False 162. In JavaScript, which of the follow operand symbols means not equal to? a. <> b. = # = c. != d. ## 163. In JavaScript, which of the follow operand symbols is the AND operator? a. &* b. && c. #AND# d. &| 164. In JavaScript, which of the follow operand symbols is the OR operator? a. |& b. |# c. #OR# d. || 165. How does the setTimeout() operate? a. it calls a function or evaluates an expression after a set period of time b. it calls a function

the number of times indicated by the number in parentheses c. it causes loading of the Web page to pause for a set length of time d. it causes the Web page to scroll after a set length of time 166. What is recursion? a. JavaScript programming technique to reload Web pages automatically b. programming technique to have a scrolling message J 2.18 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms c. JavaScript programming technique to pause a function continuously d. programming technique used to call the same function from within the same function 167. What kind of problems can the use of recursive calls create? a. load too many Web pages at once b. execute too many functions at once c. cause infinite loops or stack overflows d. keep the modem from downloading more data 168. The document object works with the and event handlers a. onload, onunload b. onclick, onout c. onclick, onunload d. onsubmit, onreset 169. The image object

works with the and event handlers a. onload, onclick b. onmouseover, onenlarge c. onfocus, onblur d. onload, onabort 170. Which property must be used in an object name to assign a variable or literal to that object (i.e, a text box?) a. focus() b. name c. value d. tag 171. What does "setting the focus" mean? a. giving the attention to an object b. making an image clearer c. putting the mouse on the object d. clicking the object icon 172. Why is form validation an important feature of JavaScript? a. validation is not necessary, HTML validates forms automatically b. testing and execution is completed on the users machine, reducing waiting time c. results are stored on the users computer d. information about the users computer must be known before validation can begin JavaScript Instructor’s Materials J 2.19 173. Which of the following built-in functions converts string values to numbers and executes the expression? a. eval() b. parseInt() c.

parseFloat() d. isNaN() 174. Which of the following built-in functions returns a Boolean condition of True or False? a. eval() b. parseInt() c. parseFloat() d. isNaN() 175. Which of the following built-in functions converts string values to integers, stripping any decimal value? a. eval() b. parseInt() c. parseFloat() d. isNaN() 176. Which of the following built-in functions converts string values to a floating point number? a. eval() b. parseInt() c. parseFloat() d. isNaN() 177. For what purpose is the Math pow() method used? a. convert decimal values to binary, octal, or hexadecimal b. multiply a value by the exponent value c. find the square root of a value d. raise a value to the power of an exponent value 178. The indexOf() method returns a value that is a. the length of a string of characters b. the position of an item in an array of characters c. the position of any character found in a string of characters d. Boolean (True or False) J 2.20 Project 2 Creating

Pop-up Windows, Adding Scrolling Messages, and Validating Forms 179. In the indexOf() method, if the search value in a string of characters is not found a is returned. a. -1 b. 0 c. 1 d. 2 180. Given the following string: "napoleon@waterloocom" what is the position of the @ sign using the indexOf() method? a. 7 b. 8 c. 9 d. -1 True/False T F 156. A simple way to attract the attention of a site visitor is to add a scrolling message to the page. T F 157. A scrolling message only can display on the status line of the Web browser T F 158. You need to call the Marquee() built-in function to display a scrolling message T F 159. In a scrolling message, you must define the location where the message will display. T F 160. If using a text box to display a scrolling message, you must name the form and the text box object. T F 161. The message in a scrolling message is assigned to a text box object by the document property. T F 162. The size attribute in a form

text box indicates the length of the message T F 163. Because visitors always look at the status bar, Web developers agree that is the best place to assign a scrolling message. T F 164. The beginning position assigned in a scrolling message indicates on which character in the message to start displaying. T F 165. One way to increment a variable by one is to write "variable++1" in the JavaScript code. T F 166. The most common way to increment a variable by one is to write "variable+=1" JavaScript Instructor’s Materials J 2.21 T F 167. The use of the substring() method in a scrolling message is to determine the next available character to insert in the message. T F 168. A condition is any expression that evaluates to a value greater than zero T F 169. When writing an If statement, you must place the condition inside a pair a parentheses. T F 170. The relational operand for equal to is a single equal sign (=) T F 171. The relational operand for

not equal to is double equal signs (= =) T F 172. The logical operator for an AND condition is two ampersands (&&) T F 173. In the setTimeout() method, the time delay is measured in minutes T F 174. Recursion is a programming technique used to call the same function from within the same function. T F 175. An event is a user action, controlled by an event handler T F 176. Event handler names are case sensitive and must begin with an uppercase letter T F 177. All event handlers work with every HTML tag and object T F 178. The onsubmit event handler works with the form objects T F 179. The onclick event handler works with submit button object T F 180. The HTML anchor tag is signified by the </HREF> T F 181. Setting the focus means giving attention to an object T F 182. To set the focus, use the JavaScript statement Set Focus To followed by the object name. T F 183. It is not possible to validate Web page forms with JavaScript T F 184. To validate a

form using JavaScript, the form is sent back to the server to be evaluated. T F 185. In an IfElse JavaScript statement, both the If and Else statements test a condition. T F 186. When a user triggers an event handler that calls a function, processing stays within that function until all statements are executed. T F 187. The eval() built-in function is the same as an IfElse statement J 2.22 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms T F 188. The parseInt() built-in function converts a string value to an integer T F 189. The parseFloat() built-in function needs a base number that determines how many decimal places to be used. T F 190. The isNaN() built-in function returns an ASCII equivalent number if the value in the parentheses is text. T F 191. JavaScript has no way to process exponentiation at this time T F 192. The values in the parentheses used in the Mathpow() method are the number and the exponent. T F 193. You can use

and place variables in between the parentheses in the Mathpow() method. T F 194. The indexOf() returns the location of an item in an index structure T F 195. The indexOf() returns a Boolean value, to indicate it found the search string T F 196. The indexOf() cannot be used to find a particular numeral in a numeric value T F 197. If the search value is not found, the indexOf() method returns a zero T F 198. A loop is a series of statements that execute repeatedly until some condition is satisfied. T F 199. The For loop needs three parameters: start value, stop value, and counter-control value. T F 200. The counter-control value in a For loop is an expression T F 201. The counter-control value cannot use subtraction T F 202. The While loop can use string values in the condition to terminate the loop T F 203. A pop-up window is another browser window that displays over the original T F 204. In the window open() method, a default pop-up window appears if a filename is

not provided. T F 205. You can eliminate the menu, toolbar, and URL location bar in the new pop-up window. JavaScript Instructor’s Materials J 2.23 Short Answer 231. Companies often use to highlight breaking news, key products, or special promotions. 232. Only Microsoft Internet Explorer recognizes the Microsoft in HTML for scrolling messages. 233. In a form text box, the attribute indicates the display width of the text box 234. With JavaScript you can assign a scrolling message to either the or a(n) . 235. Because most Web page users do not look at the , most Web developers agree placing a scrolling message in a(n) is a better location. 236. The expression X++ increments the value of X by 237. A(n) is any expression that evaluates to True or False 238. When writing an If statement, you must place the condition in 239. The conditional operand != means 240.

The symbols && in a conditional operand mean 241. The symbols || in a conditional operand mean 242. The method calls a function or evaluates an expression after a specified amount of time has elapsed. 243. is a programming technique used to call the same function within the same function. 244. Although event handler names are not case sensitive, it is strongly recommended to write them in all characters. 245. The property is used to assign variables or literals to an object 246. means giving the attention to an object 247. To set the focus, use the method with the object 248. One of the most important features of JavaScript is because it is completed on the users computer and not on the server. 249. The built-in function converts string values to numbers and executes the expression. J 2.24 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating

Forms 250. The built-in function can convert a string to an integer and the base indicated. 251. The built-in function returns a Boolean condition 252. The Math pow() method accepts , , or 253. The method is used to search a string for particular value and returns the relative location of the value within the string. 254. If the search value is found in the string object, the indexOf() method returns the of the value within the string object. 255. A(n) is a series of statements that executes repeatedly until a condition is satisfied. 256. JavaScript has two types of loops: the loop and the loop 257. Both loops first to determine if the instruction in the loop are to be executed 258. The relies on a conditional statement using numeric values 259. The For Loop often is referred to as a(n) loop 260. In the For Loop, the counter-control is a(n)

indicating how to increment or decrement the counter. 261. A window that displays over the previously opened browser window is called a(n) . 262. To include a URL bar in a pop-up window, use the feature 263. To include a menu bar in a pop-up window, use the feature 264. By default, the TITLEBAR feature is set to 265. To include a toolbar, set the toolbar feature to JavaScript Instructor’s Materials J 2.25 TEST BANK ANSWERS FOR PROJECT 2 CREATING POP-UP WINDOWS, ADDING SCROLLING MESSAGES, AND VALIDATING FORMS Multiple Choice 156. a [J 2.7] 161. a [J 2.13] 166. d [J 2.15] 171. a [J 2.21] 176. c [J 2.25] 157. a [J 2.7] 162. c [J 2.13] 167. c [J 2.15] 172. b [J 2.23] 177. d [J 2.34] 158. c [J 2.8] 163. b [J 2.13] 168. a [J 2.17] 173. a [J 2.25] 178. c [J 2.36] 159. c [J 2.8] 164. d [J 2.13] 169. d [J 2.17] 174. d [J 2.25] 179. a [J 2.36] 160. d [J 2.12] 165. a [J 2.15] 170. c [J

2.19] 175. b [J 2.25] 180. b [J 2.36] True/False 181. T [J 27] 191. F [J 212] 201. F [J 217] 211. T [J 225] 221 T [J 236] 182. F [J 27] 192. T [J 213] 202. F [J 217] 212. F [J 225] 222 F [J 236] 183. F [J 27] 193. F [J 213] 203. T [J 217] 213. F [J 225] 223 T [J 238] 184. T [J 27] 194. T [J 213] 204. T [J 217] 214. F [J 225] 224 T [J 238] 185. T [J 28] 195. F [J 213] 205. F [J 220] 215. F [J 225] 225 T [J 238] 186. F [J 28] 196. F [J 213] 206. T [J 221] 216. F [J 234] 226 F [J 238] 187. F [J 28] 197. T [J 213] 207. F [J 221] 217. T [J 234] 227 T [J 238] 188. F [J 28] 198. F [J 215] 208. F [J 223] 218. T [J 234] 228 T [J 245] 189. T [J 210] 199. T [J 215] 209. F [J 223] 219. F [J 236] 229 F [J 245] 190. F [J 212] 200. T [J 216] 210. F [J 223] 220. F [J 236] 230 T [J 245] Short Answer 231. scrolling messages [J 2.7] 238. parentheses [J 2.13] 248. form validation [J 2.23] 239. not equal [J 2.13] 249. eval() [J 2.25] 232. Marquee tag

[J 2.7] 240. and [J 2.13] 250. parseInt() [J 2.25] 233. size [J 2.8] 241. or [J 2.13] 251. isNaN() [J 2.25] 234. status bar, text box 242. setTimeout() [J 2.15] 252. variables, constants, both [J 2.8] 243. Recursion [J 2.15] status bar, text box 244. lowercase [J 2.17] 253. indexOf() [J 2.36] [J 2.8] 245. value [J 2.19] 254. relative position [J 2.36] 236. one (1) [J 2.12] 246. Setting the focus [J 2.21] 255. loop [J 2.38] 237. condition [J 2.13] 247. focus() [J 2.21] 256. For, While [J 2.38] 235. [J 2.34] J 2.26 Project 2 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms 257. test a condition [J 2.38] 260. expression [J 2.38] 264. True [J 2.45] 258. For loop [J 2.38] 261. pop-up window [J 2.45] 265. Yes [J 2.45] 259. counter-controlled 262. LOCATION [J 2.45] [J 2.38] 263. MENUBAR [J 2.45]