You are currently browsing the tag archive for the 'onclick' tag.

Very cool article explaining how to click a link and get a checkbox checked at the same time.. Very handy at times.

——————————————–

Text fields and textareas are just two types of form elements. Others that we’ll look at in this lesson are checkboxes, radio buttons, and selects. Let’s discuss checkboxes first.

Checkboxes have one main property of interest: checked.

This checkbox is checked
This checkbox is not checked
If you have a form named the_form and a checkbox named the_checkbox you can see if the checkbox has been checked like this:

var is_checked = window.document.the_form.the_checkbox.checked;
if (is_checked == true)
{
  alert("Yup, it's checked!");
} else {
  alert("Nope, it's not checked.");
}

As you can see, if a checkbox is checked, the checked property will be true. true is a built-in JavaScript datatype, so you don’t have to put it in quotes when checking it. If the checkbox is not checked, the checked property will be false (also a built-in datatype).

Just like you can read the checked property, you can set the checked property. Here’s an example of checking and setting the checked property of a checkbox:

Read more at: http://www.webmonkey.com/webmonkey/98/04/index3a_page7.html

Pages

 

November 2009
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

RSS Example RSS Real Estate Feed

  • An error has occurred; the feed is probably down. Try again later.