Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts checkbox

 
jayasri tkb
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Struts forum.

Mark
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic