Solved

get this error:   For input string: "on"

Posted on 2006-06-21
5
279 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java example issue 5 66
Running JavaFX on the Raspberry Pi 27 289
Java class and jar 3 61
batch vs regular insert in spring DAO 2 50
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

734 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