aspose file tools*
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts checkbox" Watch "struts checkbox" New topic
Author

struts checkbox

jayasri tkb
Greenhorn

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
Marshal

Joined: May 26, 2003
Posts: 30780
    
157

Jaya,
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.


[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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Moving this to the Struts forum.

Mark


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.

Example:

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


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts checkbox