Solved

get this error:   For input string: "on"

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 239
How to execute a Python program and gather return output in Java 2 49
eclipse console opening separately 2 37
Selenium docs api java index 3 66
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

749 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