« Home « Kết quả tìm kiếm

Appendix C_ Answers to Tutorial Exercises


Tóm tắt Xem thử

- T his appendix provides answers to the tutorial.
- document.myPicture document.entryForm.
- document.entryForm.nameField document.entryForm.addressField document.entryForm.phoneField document.entryForm.noArchiveBox.
- <INPUT TYPE=”button” NAME=”Hi” VALUE=”Howdy” onClick=”alert(‘Hello to you, too!’)”>.
- <SCRIPT LANGUAGE=”JavaScript”>.
- document.write(“Hello, world.
- w wr ri it te e a a w we el lc co om me e m me es ss sa ag ge e t to o t th he e w wo or rl ld d document.write(“Hello, world.”).
- <TITLE>An onLoad= script</TITLE>.
- alert(“The page has finished loading.
- alert(“Ouch.
- <BODY onLoad=”done()”>.
- <INPUT TYPE=”button” NAME=”oneButton” VALUE=”Press Me!”.
- onClick=”alertUser()”>.
- parseInt(document.forms[0].entry.value).
- You can use the parseFloat() functions either on the variable assignment expressions (for example, var value1 = parseFloat(document.adder.inputA.value.
- or in the addition expression ( document.adder.output.value = parseFloat(value1.
- var selectedState = document.entryForm.entry.value for ( var i = 0.
- USStates.length.
- <FORM NAME=”entryForm”>.
- <INPUT TYPE=”text” NAME=”entry”>.
- <INPUT TYPE=”button” VALUE=”Look Up Entry Date”.
- onClick=”getStateDate()”>.
- “.<BR>”.
- document.write(output).
- runs as document loads document.write(hisDog.
- var selectedPlanet = document.entryForm.entry.value for ( var i = 0.
- document.entryForm.output.value = msg.
- <INPUT TYPE=”button” VALUE=”Look Up a Planet”.
- onClick=”getPlanetData()”>.
- <BR>.
- <INPUT TYPE=”text” SIZE=70 NAME=”output”>.
- window.document.forms[0].
- Where’s the document ? It should be.
- self.document.entryForm.entryField.value .
- document.write(“<H1>Welcome to my Web page.</H1>”).
- document.write(“Welcome to my web page.
- <BODY onLoad=”showLocation()”>.
- For Listing 9-1, pass the text object because that’s the only object involved in the entire transaction..
- <TITLE>Text Object value Property</TITLE>.
- field.value = field.value.toUpperCase().
- <FORM onSubmit=”return false”>.
- <INPUT TYPE=”text” NAME=”convertor” VALUE=”sample”.
- onChange=”upperMe(t th hi is s)”>.
- <TITLE>Checkbox Inspector</TITLE>.
- alert(“The box is checked.
- alert(“The box is not checked at the moment.
- <INPUT TYPE=”checkbox” NAME=”checkThis”>Check here<BR>.
- <INPUT TYPE=”button” VALUE=”Inspect Box”.
- .f fo or rm m)”>.
- <TITLE>Extracting Highlighted Radio Button</TITLE>.
- form.stooges.length.
- if (form.stooges[i].checked).
- form.stooges[i].value.
- <INPUT TYPE=”radio” NAME=”stooges” VALUE=”Moe Howard” CHECKED>Moe.
- <INPUT TYPE=”radio” NAME=”stooges” VALUE=”Larry Fine” >Larry.
- <INPUT TYPE=”radio” NAME=”stooges” VALUE=”Curly Howard” >Curly<BR>.
- <INPUT TYPE=”button” NAME=”Viewer” VALUE=”View Full Name...”.
- Pass only that object to the function..
- <TITLE>Select Navigation</TITLE>.
- location = list.options[list.selectedIndex].value.
- <SELECT NAME=”urlList” onChange=”goThere(t th hi is s)”>.
- <OPTION SELECTED VALUE=”index.html”>Home Page.
- <OPTION VALUE=”store.html”>Shop Our Store.
- <OPTION VALUE=”policies”>Shipping Policies.
- <OPTION VALUE=”http://www.yahoo.com”>Search the Web.
- The Submit button is replaced with a standard button whose VALUE attribute is set to “Submit.” The button’s onClick=.
- <TITLE>Validator</TITLE>.
- form.elements.length.
- if (form.elements[i].value.
- form.submit() return.
- First Name:<INPUT TYPE=”text” NAME=”firstName” ><BR>.
- Last Name:<INPUT TYPE=”text” NAME=”lastName” ><BR>.
- Rank:<INPUT TYPE=”text” NAME=”rank” ><BR>.
- Serial Number:<INPUT TYPE=”text” NAME=”serialNumber” ><BR>.
- <INPUT TYPE=”button” VALUE=”Submit” onClick=”checkForm(this.form)”>.
- The this keyword refers to the text field object, so this.value refers to the value property of that object..
- document.accessories.acc1.value = “Leather Carrying Case”.
- document.forms[1].acc.value = “Leather Carrying Case”.
- <TITLE>Color Changer</TITLE>.
- var newColor = list.options[list.selectedIndex].value document.bgColor = newColor.
- <SELECT onChange=”setColor(this)”>.
- <OPTION VALUE=”red”>Stop.
- <OPTION VALUE=”yellow”>Caution.
- <OPTION VALUE=”green”>Go.
- <TITLE>E-mail Validator</TITLE>.
- if (form.email.value.indexOf.
- <FORM onSubmit=”return checkAddress(this)”>.
- <INPUT TYPE=”text” NAME=”email” SIZE=30><BR>.
- <INPUT TYPE=”submit”>.
- var inputString = form.mainstring.value.toUpperCase() f.
- alert(“The string has.
- form.die1.value = Math.round(Math.random.
- 1 form.die2.value = Math.round(Math.random.
- <INPUT TYPE=”text” NAME=”die1” SIZE=2>.
- <INPUT TYPE=”text” NAME=”die2” SIZE=2><BR>.
- <INPUT TYPE=”button” VALUE=”Roll the Dice”.
- onClick=”roll(this.form)”>.
- <TITLE>Waiting for Santa</TITLE>.
- document.write(daysToXMAS.
- document.images[“people”].src = janeImg.src

Xem thử không khả dụng, vui lòng xem tại trang nguồn
hoặc xem Tóm tắt