• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set check/unckeck Checkbox using database value

 
Tushar tej
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

I am displaying a jsp page with 3 columns 1> complaint_no, 2>user_id, 3>attend_yn.
The 3rd col. attend_yn will be checkbox.
When user logs in he will see complaints assigned to him, he will select one or more complaint_no which he will attend.

My problem is how to handle checkbox value.
The value of attend_yn='A' when checked by user and attend_yn='N' when user doesn't select any or deselect existing selected complaint.

I want to show the checkbox checked when attend_yn='A' and unchecked when attend_yn='N'.



For checkbox "attendchk" how to set value 'A' and checked as retrieved from database and value to 'N' and unchecked .

I am able to loop through complaint_no but without values of checkbox as 'A' or 'N' I cannot update database.

In AttendOKUIB.jsp I have some code as


Hope I am clear
Please advice

Tushar
[ December 26, 2008: Message edited by: Tushar tej ]
 
Sunil Kumar
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the value in the scriplet



Here i am assuming that the only value other than A would be N
If that is not the case, i hope you got the idea and can change the above code as per you data points
[ December 26, 2008: Message edited by: Sunil Kumar ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better yet, step out of 2001 and avoid scriptlets by using the JSTL and EL.

For conditionals you can use the JSTL's <c:if> action, or the EL's ternary operator (?).
[ December 26, 2008: Message edited by: Bear Bibeault ]
 
Tushar tej
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Sunil bhai thanks every much you solved my problem.

Hi,
Bear Bibeault still learning JSP and will also look into JSTL and EL.

My good luck I found this forum.
Thanks both of you.

Tushar
[ December 26, 2008: Message edited by: Tushar tej ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are just learning JSP, I'd suggest learning the right and modern way of doing things right off the bat and to be sure and avoid scriptlets entirely.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add this to your web.xml to force yourself into a scriptletless way:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic