File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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: 32815

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]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Moving this to the Struts forum.


Perfect World Programming, LLC - iOS Apps
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
I agree. Here's the link:
subject: struts checkbox
jQuery in Action, 3rd edition