Author
Struts 2 - disable a checkboxlist using javascript
Rodrigo Bossini
Ranch Hand
Joined: Jul 03, 2009
Posts: 106
Hi,
I'm using struts 2 on a web project I'm working on. I'm new at web development.
I'm using a struts 2 tag, checkboxlist, to give the user some options to select.
I have also a radio, which when clicked should enable or disable the checkboxlist, depending on the choice made by the user.
The problem is that I can't seen to do it by using javascript.
I have a script that disables text fields, radio fields, but that can't disable the checkboxlist.
Has anyone seen this issue before?
I see wind mills
Dejan Mratinkovic
Ranch Hand
Joined: Nov 20, 2008
Posts: 65
Hi,
This is more of java script than java question. Check http://cn.w3schools.com/jsref/prop_checkbox_disabled.asp , there you will find working example how to disable check box.
You should see how struts renders your check box (depends on theme you choose), and then figure out how to write java script for it.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Dec 01, 2009 05:51:18
0
As the previous poster implies, you'll actually need to disable each individual checkbox--HTML doesn't have the concept of a "checkbox list".
The code would be a one-liner using jQuery, Prototype, or similar.
Rodrigo Bossini
Ranch Hand
Joined: Jul 03, 2009
Posts: 106
Do you guys have a suggestion on how to disable the components using something other than pure javascript?
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Dec 01, 2009 13:13:05
0
I don't possibly see how--you're trying to act on an event, and that means JavaScript.
Another option would be to submit the form and redraw the entire page, checking a flag to see if the radiobox list should be rendered as disabled or not.
subject: Struts 2 - disable a checkboxlist using javascript