Matt Simoncavage
Posts: 0
Joined: Thu Jun 04, 2015 7:10 pm

Javascript not working in app

Hi, I have a client who would like to turn a javascript calculator running on his website into an app. There are several calculators, but I'll include the code for one here for an example. It functions correctly on a website, but when I add it to appery it will not work.

This is the code for the calculator itself, which I am placing in an HTML component:

< form name="do2form"
Dissolved oxygen: < input name="do2" type="text" / (%sat) < input onclick="calcdo2wqi()" type="button" value="Calculate" / < input name="do2wqi" type="text" / Water quality index:< /form

This is the javascript that goes with it, which I am running on Page Load:

function calcdo2wqi()
{
var intext=document.do2form.do2;
var outtext=document.do2form.do2wqi;
var xarray=new Array(0.0,16.0,20.0,32.0,34.0,62.0,67.0,70.0,74.0,80.0,84.0,90.0,94.0,98.0,102.0,106.0,137.0,140.0);
var yarray=new Array(2.0,10.0,12.0,20.0,22.0,60.0,70.0,75.0,80.0,87.0,90.0,95.0,98.0,99.0, 99.0, 98.0, 80.0,78.0);
var inval,outval;
var cnt=18;

Code: Select all

                             if (intext.value=="") 
                             { 
                                     inval=intext.value; 
                                     outval="Blank"; 
                             } 
                             else 
                             { 
                                     inval=parseFloat(intext.value); 
                                     if (inval140) 
                                             { 
                                                     outval="50"; 
                                             } 
                                             else 
                                             { 
                                                      outval=Math.round(dattowqi(inval,cnt,xarray,yarray)); 
                                             } 
                                     } 
                             } 
                             intext.value=inval; 
                             outtext.value=outval; 
                     } 

Any input as to why this isn't working and how I might be able to edit the code to make it work would be great. Thanks!

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Javascript not working in app

Hello Matt,

Could you please clarify do you have any errors in a browser console?

Matt Simoncavage
Posts: 0
Joined: Thu Jun 04, 2015 7:10 pm

Javascript not working in app

Hi Evgene,

There are no errors. Just nothing's happening. Like I said, everything works perfectly on the website where it's being used (you can even take a look here: http://www.water-research.net/index.p... ). I'm running the script on page load, is there another way I can run the script? Or is the particular script just not compatible?

Thanks.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Javascript not working in app

Dear Matt,

I have this error in console when trying to execute calculator:
ReferenceError: calcdo2wqi is not defined
Please check your code.

Return to “Issues”