• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to set check/unckeck Checkbox using database value

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add this to your web.xml to force yourself into a scriptletless way:

reply
    Bookmark Topic Watch Topic
  • New Topic