This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Struts and the fly likes struts checkbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts checkbox" Watch "struts checkbox" New topic

struts checkbox

jayasri tkb

Joined: Dec 13, 2005
Posts: 1
In my struts application, i have a jsp that uses <html:checkbx>
I want to check the status of the checkbox, whether it is checked or not, in the onclick method.
Any suggestions?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31588

Welcome to JavaRanch! For the future, note that we have a forum dedicated to Struts lower on the page.

You can access the Struts checkbox through the JavaScript: document.myForm.myCheckBox

MyForm is whatever your form is named. You can check the struts-config file or just look at the generated HTML code. myCheckBox is the name of your form property for the checkbox.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17260

Moving this to the Struts forum.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you're going to call a javascript function from the onclick method of a checkbox, the easiest way find out if the box is checked is by using the reference: this.checked. It will evaluate to true if the user has just caused the box to be checked by clicking on it, and false if the user has caused the box to be unchecked.


<html:checkbox property="myBox" value="true" onklick="myJSFunction(this.checked)" />

Consultant, Sima Solutions
subject: struts checkbox