157Chapter 15 .Generic HTML Element Objects Form elements (Web server setup)

157Chapter 15 .Generic HTML Element Objects Form elements The blur() and focus()methods apply primarily to text-oriented form controls: text input, SELECT, and TEXTAREA elements. Just as a camera lens blurs when it goes out of focus, a text object blurs when it loses focus when someone clicks or tabs out of the field. Under script control, blur() deselects whatever may be selected in the field, and the text insertion pointer leaves the field. The pointer does not proceed to the next field in tabbing order, as it does if you perform a blur by tabbing out of the field manually. For a text object, having focus means that the text insertion pointer is flashing in that text object s field. Giving a field focus is like opening it up for human editing. Setting the focus of a text field or TEXTAREA does not, by itself, enable you to place the cursor at any specified location in the field. The cursor usually appears at the beginning of the text. To prepare a field for entry to remove the existing text, use both the focus() and select() methods in series. Be aware, however, that the focus() method does not work reliably in Navigator 3 for UNIX clients: While the select() method selects the text in the designated field, focus is not handed to the field. One other caveat about using focus()and select() together to preselect the content of a text field for immediate editing: Many versions of Internet Explorer fail to achieve the desired results due to an internal timing problem. You can work around this problem (and remain compatible with Navigator) by initiating the focus and selection actions through a setTimeout() method. See Chapter 43 on data validation for an example. A common design requirement is to position the insertion pointer at the end of a text field or TEXTAREA so that a user can begin appending text to existing content immediately. This is possible in IE4+ with the help of the TextRangeobject. The following script fragment moves the text insertion pointer to the end of a TEXTAREA element whose ID is myTextarea: var range = document.all.myTextarea.createTextRange() range.move( textedit ) range.select() You should be very careful in combining blur() or focus()methods with onBlur and onFocusevent handlers especially if the event handlers display alert boxes. Many combinations of these events and methods can cause an infinite loop in which it is impossible to dismiss the alert dialog box completely. On the other hand, there is a useful combination for older browsers that don t offer a disabled property for text boxes. The following text field event handler can prevent users from entering text in a text field: onFocus = this.blur() Some operating systems and browsers enable you to give focus to elements such as buttons (including radio and checkbox buttons) and hypertext links (encompassing both A and AREA elements). Typically, once such an element has focus, you can accomplish the equivalent of a mouse click on the element by pressing the spacebar on the keyboard. This is helpful for accessibility to those who have difficulty using a mouse. elementObject.blur()
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply