Solved

get this error:   For input string: "on"

Posted on 2006-06-21
5
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.
Suggested Courses

617 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