wood burning stoves 2.0*
The moose likes Struts and the fly likes Checkbox on show div tag when the page is loaded Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checkbox on show div tag when the page is loaded" Watch "Checkbox on show div tag when the page is loaded" New topic
Author

Checkbox on show div tag when the page is loaded

Jayasri Alaparthi
Ranch Hand

Joined: Aug 14, 2006
Posts: 67
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

Joined: Jun 07, 2007
Posts: 72

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.


- Marimuthu Madasamy
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Checkbox on show div tag when the page is loaded
 
Similar Threads
Struts checked checkbox
JSP <a href> tags breaks page functionality
Check box checked and loaded first time have to show div tag
problem with check box
How to check a checkbox automatically in struts