This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Set the Checked attribute of Check Box 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 » Java » JSP
Bookmark "Set the Checked attribute of Check Box" Watch "Set the Checked attribute of Check Box" New topic
Author

Set the Checked attribute of Check Box

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
If I am using JSTL to populate a table and one of my columns is a check box and the value of the item for the cell is 1 or 0, how can I set the checked attribute based on this value?

Seems I need a condition within the input tag like

if value = 1 checked
[ July 18, 2008: Message edited by: Steve Dyke ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60737
    
  65

Assuming JSP 2.0 you can easily include or exclude any template text (such as HTML pieces-parts) using the EL's ternary operator.

For example:


Your turn.
[ July 18, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: Set the Checked attribute of Check Box
 
Similar Threads
Does this work for checkbox ?
Enable combo box when check box is checked
validating textfield with +ve/-ve values using 2 radiobuttons
jsp page checkbox issue
checkbox in jsp