Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Conver to decimal value

Posted on 2006-04-22
4
Medium Priority
?
599 Views
Last Modified: 2006-11-18
I have a javascript result that I need converted to a decimal.  Here is the line:

worksheet.Total.value = parseInt(Innovator) + parseInt(MktLdr) + parseInt(MajorCompetitor) + parseInt(MinorCompetitor)

Your help is appreciated.

John
0
Comment
Question by:jcpatterson
  • 2
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 16515112
You mean this?

var v = parseFloat(Innovator) + parseFloat(MktLdr) + parseFloat(MajorCompetitor) + parseFloat(MinorCompetitor);
worksheet.Total.value = v.getFixed(2);

-r-
0
 
LVL 1

Author Comment

by:jcpatterson
ID: 16515839
Hello Roonaan,

Thanks for your reply.  You are onto what I am trying to do and that is converting to two decimal points.

I applied your recommendation and IE returns: Object doesn't support this property or method

Firefox debugger highlights the "worksheet.Total.value = v.getFixed(2)" line as the problem.

Here is the entire script in case you need to see it:

<script language="JavaScript">
function Scores() {

var iA1 = worksheet.A1.value
var iA2 = worksheet.A2.value
var iA3 = worksheet.A3.value
var iA4 = worksheet.A4.value  
var iB1 = worksheet.B1.value
var iB2 = worksheet.B2.value
var iB3 = worksheet.B3.value
var iB4 = worksheet.B4.value  

Innovator = parseInt(iA1) * parseInt(iB1)
MktLdr = parseInt(iA2) * parseInt(iB2)
MajorCompetitor = parseInt(iA3) * parseInt(iB3)
MinorCompetitor = parseInt(iA4) * parseInt(iB4)

var v = parseInt(Innovator) + parseInt(MktLdr) + parseInt(MajorCompetitor) + parseInt(MinorCompetitor)

 worksheet.Total.value = v.getFixed(2)
 
}
</script>

Thanks, John
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 1000 total points
ID: 16515878
Sorry, indeed it should be v.toFixed(2) rather than v.getFixed(2).

-r-
0
 
LVL 1

Author Comment

by:jcpatterson
ID: 16516141
Thanks for your help on a Saturday.

John
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 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