wood burning stoves*
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
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: 1439
    
    1
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: 61103
    
  66

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]
 
Consider Paul's rocket mass heater.
 
subject: Set the Checked attribute of Check Box