This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Is Checkbox checked by name? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Is Checkbox checked by name?" Watch "Is Checkbox checked by name?" New topic
Author

Is Checkbox checked by name?

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
This code seems to always act as is check box is checked even when I un check it.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60808
    
  65

The expression $("input[name='usertextmsgcntrl']:checked") always returns a jQuery wrapped set, which is truthy, so the expression always evaluates to true.

What you want to check is the length of the set. If the checkbox is checked the wrapped set will not be empty.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
Thanks Bear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Checkbox checked by name?
 
Similar Threads
checkbox
How to add the objects to the arraylist class if object has many states
What does this error mean??
NullPointerException when removing objects, for which equals() is overriden, from JComboBox
get value from radio button