15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

}<br />

Chapter 9 ✦ Text-Related Form Objects (Chapter 25)<br />

setTimeout(“doSelection(document.” + formName + “. “ + fldName + “)”, 0)<br />

function doSelection(fld) {<br />

fld.focus()<br />

fld.select()<br />

}<br />

<br />

<br />

<br />

<br />

Enter any positive integer: <br />

<br />

<br />

<br />

<br />

Event handlers<br />

onBlur<br />

onFocus<br />

onSelect<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓<br />

Example<br />

To demonstrate one of these event handlers, Listing 25-5 shows how you may<br />

use the window’s statusbar as a prompt message area after a user activates any<br />

field of a form. When the user tabs to or clicks on a field, the prompt message associated<br />

with that field appears in the statusbar. In Figure 9-1, the user has tabbed to<br />

the second text box, which caused the statusbar message to display a prompt for<br />

the field.<br />

Listing 25-5: The onFocus event Handler<br />

<br />

<br />

Elements Array<br />

<br />

Continued<br />

365<br />

document.formObject.textObject.onBlur

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!