aspose file tools
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 The Software Craftsman this week in the Agile 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: 1519
    
    1
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: 62312
    
  68

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: 1519
    
    1
Thanks Bear.
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: Is Checkbox checked by name?