Solved

get this error:   For input string: "on"

Posted on 2006-06-21
5
270 Views
Last Modified: 2010-03-31
when I try to parse the value of a checkbox to an int I get this error


here is my code

int display_add = UploadUtil.getInputValue("DISPLAY_ADD",
                input_fields.iterator()) == null || UploadUtil.getInputValue("DISPLAY_ADD",
                input_fields.iterator()).length() == 0  ? 0 :
                Integer.parseInt(UploadUtil.getInputValue("DISPLAY_ADD",
                input_fields.iterator()));

any help will be grealy appreciated
0
Comment
Question by:huzefaq
  • 2
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 16956134
looks like it isn't expecting the value of your checkbox to be "on"
0
 

Author Comment

by:huzefaq
ID: 16956661
objects can u please elaborate what do u mean by that

I thought if the checkbox is checked it's value should be 1
and if it is not its value should be 0

is that right?

Thanks
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 16956695
no, be default a checked checkbox will return a value of "on"
unchecked will return no value
you can set the value of the checkbox usiong the value attribute in the <intput> tag
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 250 total points
ID: 16957663
You will need to add a check before you use it something like

Integer.parseInt(UploadUtil.getInputValue("DISPLAY_ADD", input_fields.iterator()).equals("on") ? 0 : 1);

so whenever it is on it will return 0 and whenever it is nothing it will return 1. Modify the source code accordingly.
0
 
LVL 35

Expert Comment

by:girionis
ID: 16961420
Thank you for accepting, glad I was of help :)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now