Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding Value of Checkboxes by Name

 
Steve Dyke
Ranch Hand
Posts: 1642
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: 1642
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
Pie
Posts: 65105
89
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic