Đang chuẩn bị liên kết để tải về tài liệu:
JavaScript Bible, Gold Edition part 200

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

JavaScript Bible, Gold Edition part 200. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | CD-482 Part VI Appendixes Checkbox Input Object Properties checked NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility Example The simple example in Listing 24-2 passes a form object reference to the JavaScript function. The function in turn reads the checked value of the form s checkbox object checkThis.checked and uses its Boolean value as the test result for the i f.else construction. Listing 24-2 The checked Property as a Conditional HTML HEAD TITLE Checkbox Inspector TITLE SCRIPT LANGUAGE JavaScript function inspectBox form if form.checkThis.checked alertCThe box is checked. else alertCThe box is not checked at the moment. SCRIPT HEAD BODY FORM INPUT TYPE checkbox NAME checkThis Check here P INPUT TYPE button NAME boxChecker VALUE Inspect Box onClick inspectBox this.form FORM BODY HTML document.formObject.checkboxObject.checked Appendix F Examples from Parts III and IV CD-483 defaultChecked NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility Example The function in Listing 24-3 this fragment is not in the CD-ROM listings is designed to compare the current setting of a checkbox against its default value. The if construction compares the current status of the box against its default status. Both are Boolean values so they can be compared against each other. If the current and default settings don t match the function goes on to handle the case in which the current setting is other than the default. Listing 24-3 Examining the defaultChecked Property function compareBrowser thisBox if thisBox.checked thisBox.defaultChecked statements about using a different set of HTML pages value NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility Example The scenario for the skeleton HTML page in Listing 24-4 is a form with a checkbox whose selection determines which of two actions to follow for submission to the server. After the user clicks the Submit button a JavaScript function examines the checkbox s checked property. If the property is true the button is