A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: export problem with math in javascript

  1. #1
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    The following javascript code works in preview but not in browser.. I get NaN (not a number) instead of correct answer


    Needed this so it was redone in the actions but boy is it ugly that way
    Code:
    function Clog(x){
    	LogConstant=log(10);
    	return log(x)/LogConstant;
    	}
    	
    A=(Clog(tds)-1)/10;
    temp2=((temp-32)*(5/9))-(-273);
    B = Clog(temp2) * -13.12 +34.55;
    C= Clog(calcium)-0.4;
    D = Clog(alkalinity);
    
    ph2=(9.3+A+B)-(C+D);
    result=ph2;
    lsi = ph-ph2;
    si=lsi;

  2. #2
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681
    Hi Bret,

    The only thing that I can think of is that one of the variables is a string instead of a number. The variables would be temp2, calcium and alkalinity.

    The log() function returns the NaN when the expression is non-numeric.

    From the code I can't see what get's loaded into temp (used to formulate the result for temp2), calcium or alkalinity.

    HTH to sort this out. I don't mind having a closer look at the code if you like. Send it via email or post a link and I'll be only too happy.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Originally posted by kusco
    Hi Bret,

    The only thing that I can think of is that one of the variables is a string instead of a number. The variables would be temp2, calcium and alkalinity.

    The log() function returns the NaN when the expression is non-numeric.

    From the code I can't see what get's loaded into temp (used to formulate the result for temp2), calcium or alkalinity.

    HTH to sort this out. I don't mind having a closer look at the code if you like. Send it via email or post a link and I'll be only too happy.
    They are just editboxes and I've entered numbers
    temp 84
    akalinity 100
    and calcium 300
    tsd=1200

    for testing
    It works fine in the preview and only has this upon export. I redid it using action scripting and it works but the coding is very ugly... Had to use compond formulas since I couldn't create a function. I have the thing working now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center