- This topic has 4 replies, 2 voices, and was last updated 12 years, 4 months ago by Celeste Patin.
-
AuthorPosts
-
Celeste PatinMemberPlease–Can someone help?
Attached is my APP.
If you put numbers in the WKLY Sales screen and enter the number of weeks and the number of days in the week results in numbers with 8 or 9 digits after the decimal point. I only want 2 after the decimal point.Can you help me with the code?
Someone provided this example but I don’t understand where to put it and where to call it.
function round(z){
z=z*100;
z=Math.round(z);
z=z/100;
return(z);
}Thank you for your help.
Celeste
Attachments:
You must be logged in to view attached files.
KaleMemberHi,
the function can be placed anywhere. It is a function like any other function in your code and works exactly like your functions you already have.
It is called, when you want a result to be rounded 😉
For example:
var number1 = 15;
var number2 = 3.5:
var result = round(number1/number2);The function round() is called and gets the result of number1/number2. It returns the rounded result.
In your code you would write:
//compute daily average of months
davg = round( avg / mth8);Kale
Celeste PatinMemberTHANK YOU, thank you, thank you! It worked, but of course you knew it would 🙂 !
The problem that I was having was thinking it would be an “on click” or “on change” call in the MobiOne design. Also, I was trying to substitute the z in the function for my variables (davg, avg).
I have two questions:
1 – How does js know to substitute the z with my variable (davg)? It seems that it would be looking for a variable named z or your would have to substitute your variable for the z.
2 – Can you suggest books or online learning or something that would help me? I have “Sams Teach Yourself HTML, CSS and JavaScript” by Julie Meloni, access to jquery.com and w3schools. Other suggestions?
I have to present this to my Director next week and it is more or less complete except I have to figure out how to calculate the time difference between two dates. BUT THAT CAN WAIT! For example, if a process starts on 8/14/2012 at 10:00 AM and ends on 8/15/2012 at 1:00 PM, how many days and hours is that? (14/24=.583 and 13/24=.542–.583+.542=1.12 days). BUT THAT CAN WAIT.
I can’t express how appreciative I am of your help. I realize that Octavio and Wayne are busy and this is such a great resource to have.
Thank you again.
Celeste
KaleMemberYou’re welcome.
How does js know to substitute the z with my variable (davg)? It seems that it would be looking for a variable named z or your would have to substitute your variable for the z.
Well, it does not substitute the variables. What happens is that the result of the calculation (avg/mth8), let´s say it is 6.23334267365, is passed to the function round(z)
The z is a local variable of that function and when you pass the result of the calculation, then z=6.23334267365
Then the function rounds the number to 6.23
It then returns the value back to where the function was called. NOW the variable davg gets the value of 6.23
Can you suggest books or online learning or something that would help me? I have “Sams Teach Yourself HTML, CSS and JavaScript” by Julie Meloni, access to jquery.com and w3schools. Other suggestions?
My books are all in german 😉 I don´t know any english books about javascript. Maybe someone else has a suggestion?
Kale
Celeste PatinMemberThanks again Kale. I will make this a separate topic.
-
AuthorPosts