Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSTL test if checkbox is checked

843840Apr 16 2008 — edited Apr 17 2008
Hello all,

I hope this question isn't too amateurish to answer, but it is something that has been troubling me.

I have a table with two columns. In the first column i've got a form checkbox with id="myCheckbox" and in the second column I have a bit of text that I only want displayed if the checkbox is checked. I mostly had this working through a combination of a small javascript function that was set to the onclick parameter of the checkbox to toggle between hiding and displaying the text while having the text initialize to not be displayed (with style="display:none")...

...but the problem was that if there was an error being returned in the form, the page would reload with the text hidden, but the checkbox checked. Now I could get around this by re-initializing the checkbox to being unchecked... but that's not the solution i'm looking for. Ideally, if an error were returned and the page reloaded I would like the checkbox to be checked and the text to be displayed.

I was hoping that perhaps I could use some JSTL magic to form a statement around the text... something to the effect of <c:if test="${myCheckbox.checked}"> display text </c:if> . But that isn't working for me. Am I close in my thinking? I think my thinking is mostly good, it's the implementation that is not good. Is there any way to perform such a test?

Let me know if anyone can help... thanks,
Skylar
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 15 2008
Added on Apr 16 2008
5 comments
2,281 views