Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding Value of Checkboxes by Name  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code shows every checkbox with same has a value of one even though it is not checked(should be value of 0)

 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I understand why the 'value' will not work because that is set when jsp is loaded.

What I need is to know from a set of checkboxes which ones are checked and which ones are not and this needs to be by name of set.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be checking the checked property: $(this).prop("checked")

Steve Dyke wrote:I think I understand why the 'value' will not work because that is set when jsp is loaded.

Nothing to do with JSP; the value property is set from the HTML value attribute and is completely unaffected by any change in state of the checkbox.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!