• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

How to get value of unchecked checkbox?  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am designing an attendance system. on the attendance page, there is roll no., name and present (which is a checkbox). Now what I want to do is if the checkbox is checked it will update attended and total field in my attendance table. and if it is unchecked then it will only update the total field. I am facing a problem when it is unchecked otherwise it is updating in the table.

att.jsp






For checked checkbox if condition is working but what should be else condition since i am unable to get unchecked checkbox. Suggest me something for attendance system working properly.
 
Saloon Keeper
Posts: 20639
122
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're doing several things wrong.

First, you're using scriptlets and putting Java code in a JSP. That hasn't been considered good practice for probably 20 years. For one thing, it's an absolute nightmare to debug Java code in a JSP. Use a servlet for the code and let the JSP display the results.

Secondly, the Class.forName() call is also at least 10 years obsolete at a rough guess. You don't need it even in a servlet.

Third, actually using the DriverManager to get a database connection is not the best way for a webapp to get a connection. It's better to use a server-supplied Connection Pool. But that's something you can do later when you get serious.

And finally - the answer you've been waiting for!

And the answer is... You can't do it.

HTML doesn't send back an "unchecked" indicator for unchecked checkboxes. It only sends the checked checkboxes. So the way to tell a box has not been checked it to attempt to obtain its parameter value. If you get back null - meaning that the parameter was not returned from the form - then the box is unchecked.
 
Pur Bh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is there any other option for attendance system, so that if student is present two fields of attendance table gets updated(attend and total field) and if not present then only one field(total) gets updated.
And also i can't use radio button because for the list of students displaying and their corresponding radio buttons i have used for loop, so the radio button for "present" will have same name and for only one student present can be marked. Please suggest me any approach to do that.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!