11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Color:<br />

<br />

Silver<br />

Green<br />

Red<br />

Blue<br />

Orange<br />

<br />

<br />

<br />

<br />

<br />

Unfortunately, the previous example does not work in much older browsers like Netscape 4 that<br />

lack full HTML 4 support. However, note that it is possible to simulate disabled fields in even<br />

very old browsers with a continual use of the blur() method for the ―pseudo-disabled‖ fields as a<br />

user tries to focus them. Obviously, such a technique is best left for the history books, but it is<br />

possible if extreme backward compatibility is your goal.<br />

Dynamic Forms<br />

Before concluding the chapter, let‘s present one final example of how intelligence can be added<br />

to a Web form to make it dynamic. As we have seen throughout the chapter, it is possible to<br />

both read and write form field values; thus, besides checking data and improving form usage,<br />

we should be able to use <strong>JavaScript</strong> to subtotal orders, calculate shipping values, and fill in<br />

parts of the form dynamically. <strong>The</strong> following example shows a simple form that adds up the<br />

number of items entered and calculates a subtotal, tax rate, shipping cost, and grand total. A<br />

rendering of the example is shown in Figure 14-4.

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

Saved successfully!

Ooh no, something went wrong!