Link to home
Start Free TrialLog in
Avatar of jcpatterson
jcpatterson

asked on

Conver to decimal value

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
Avatar of Roonaan
Roonaan
Flag of Netherlands image

You mean this?

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

-r-
Avatar of jcpatterson
jcpatterson

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help on a Saturday.

John