Solved

get this error:   For input string: "on"

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 196
web services creation SOAP vs REST 5 42
expectj telnet failing 5 36
Java Restore security prompts not working 10 13
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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 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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

803 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