469,307 Members | 2,211 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

set Check Box Attribute


I have a check box in my form. I was wondering how can I do the following:

when someone checks the box and hits submit, the checkbox.checked shud be checked to true. If it is unchecked, the value should be set to false.

I need to use JavaScript/DOM. Any hints?
Nov 29 '06 #1
1 1514
16,027 Expert Mod 8TB
You could set it using server-side code, but if with JavaScript, then when the document body has loaded:
Expand|Select|Wrap|Line Numbers
  1. checkbox.checked = true;
  2. // or alternatively:
  3. checkbox.defaultChecked = true;
  4. // you could also use setAttribute().
May 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by richardkreidl | last post: by
3 posts views Thread by shapper | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.