Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get values from checkbox

 
muthukumaran mohan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
how to get values from checkbox. assume that i have two checkbox and i want to check which checkbox is selected and which one is not selected.
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correct me if i'm wrong anyone but if your checkbox was checked when the form was submitted, it will appear in the request as a name/value pair.
if it wasn't checked, it won't appear at all.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam, you are correct. Muthukumaran, if you use getParameter(yourCheckBoxName), and null is returned it means that checkbox was not checked. Else, the checkbox is checked, and it should return the corresponding value for that checkboxname.

Bosun
 
muthukumaran mohan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Adam, can you clear me in detail, my query is that i want to store yes or no when the checkbox is clicked or not clicked.
awaiting for your early reply.
bye for now.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ad I posted earlier, In your request.getParameter(yourCheckBoxName) if it returns null, it means it's not clicked. Else, it's clicked. Store your values baased on this. Am I missing something here???

Bosun
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you want a code snippet:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic