Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checkbox on show div tag when the page is loaded

 
Jayasri Alaparthi
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I have a check box and the information of if it is checked or not, comes from Actionform get, I want the div tag to be displayed when the jsp is first loaded and the check box is checked, and the inforamtion of it I get from Action-dao-bean.

I am using logic:iterator and getting the value and property form bean

Can some one help me in sending the sample code for this.

with regards,
Bhargavi.
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets say you have a form bean with this getters and setters,



in JSP,


It is checking for the property 'symbol' in bean, if it is 'Y' then 'checked' attribute is included in the checkbox control. If it is other than 'Y', then it is not checked.

Hope it helps.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you have a situation where if a checkbox is checked then you need to show some additional fields and when the checkbox is cleared you need to hide some additional fields. Is this correct? Do you already have JavaScript code in place to do this at runtime?

To set the state when the page if first shown you can do one of two things. You could use scriptlet code or custom tags in your JSP to create the fields you need in the desired state. The other option is to call your JavaScript function when the page loads. The benefit of using JavaScript is that you don't have to implement the logic twice.

- Brent
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic