1

I am trying to convert string into integer using jquery but it throwing NumberFormatException. How to fix it?

<% int ai= Integer.parseInt(beginningBalance.get(i));%>
3
  • what is your string? Commented Sep 2, 2016 at 6:38
  • 1
    your code doesn't look like JavaScript/Jquery. Is that a Java question? Commented Sep 2, 2016 at 6:38
  • +str turns str into a number Commented Sep 2, 2016 at 6:38

2 Answers 2

1

The parseInt() function of JS parses a string and returns an integer.

Ex:

var a = parseInt("10");
Sign up to request clarification or add additional context in comments.

Comments

1

Your code is not of javascript.

<% int ai= Integer.parseInt(beginningBalance.get(i));%>

it looks like ASP.net if you want pure javascript or jquery then answer is same as provide above.

var a = parseInt("10");

so you can change your code in javascript like this:

var a = parseInt( '<% beginningBalance.get(i); %>');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.