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.

Chapter 8 ✦ Button Objects (Chapter 24)<br />

Listing 24-4: Adjusting a CGI Submission Action<br />

<br />

<br />

Checkbox Submission<br />

<br />

function setAction(form) {<br />

if (form.checkThis.checked) {<br />

form.action = form.checkThis.value<br />

} else {<br />

form.action = “file://primaryURL”<br />

}<br />

return true<br />

}<br />

<br />

<br />

<br />

<br />

Use<br />

alternate<br />

<br />

<br />

<br />

<br />

Event handlers<br />

onClick<br />

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

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

Example<br />

The page in Listing 24-5 shows how to trap the click event in one checkbox to<br />

influence the visibility and display of other form controls. After you turn on the<br />

Monitor checkbox, a list of radio buttons for monitor sizes appears. Similarly,<br />

engaging the Communications checkbox makes two radio buttons visible. Your<br />

choice of radio button brings up one of two further choices within the same table<br />

cell (see Figure 8-1).<br />

349<br />

document.formObject.checkboxObject.onClick

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

Saved successfully!

Ooh no, something went wrong!