aspose file tools*
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 Java 8 in Action this week in the Java 8 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: 1391
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: 60077
    
  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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set the Checked attribute of Check Box
 
Similar Threads
validating textfield with +ve/-ve values using 2 radiobuttons
Enable combo box when check box is checked
jsp page checkbox issue
Does this work for checkbox ?
checkbox in jsp