tailieunhanh - JavaScript Bible, Gold Edition part 201

JavaScript Bible, Gold Edition part 201. 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-492 Part VI Appendixes Chapter 25 Examples The following sections contain examples from Chapter 25 Text-Related Form Objects. Text Input Object Properties defaultvalue NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility Example Important Listings 25-1 25-2 and 25-3 feature a form with only one text INPUT element. The rules of HTML forms say that such a form submits itself if the user presses the Enter key whenever the field has focus. Such a submission to a form whose action is undefined causes the page to reload thus stopping any scripts that are running at the time. FORM elements for of these example listings contain an onSubmit event handler that both blocks the submission and attempts to trigger the text box onChange event handler to run the demonstration script. In some browsers such as IE5 Mac you may have to press the Tab key or click outside of the text box to trigger the onChange event handler after you enter a new value. Listing 25-1 has a simple form with a single field that has a default value set in its tag. A function resetField restores the contents of the page s lone field to the value assigned to it in the INPUT definition. For a single-field page such as this defining a TYPE reset button or calling works the same way because such buttons reestablish default values of all elements of a form. But if you want to reset only a subset of fields in a form follow the example button and function in Listing 25-1. Listing 25-1 Resetting a Text Object to Default Value HTML HEAD TITLE Text Object DefaultValue TITLE document. Appendix F Examples from Parts III and IV CD-493 SCRIPT LANGUAGE JavaScript function upperMe field function resetField form SCRIPT HEAD BODY FORM onSubmit return false Enter lowercase letters for conversion to uppercase INPUT TYPE text NAME converter VALUE sample onChange upperMe this .

TỪ KHÓA LIÊN QUAN