|
View Poll Results: Macs and javascript: to be or not to be, that is the question. | |
A match made in heaven, like summer & ice cream!
|    | 0 | 0% | |
Like McDonalds with healthy food, Mac's not there yet...but they are trying.
|    | 1 | 100.00% | |
Umm, something's wrong,...and I don't think they're trying.
|    | 0 | 0% | |
What's Mac got to do...(i said) got to do with it!?...
|    | 0 | 0% | Javascript in Mac: Number.toFixed challenge 
February 7th, 2006, 11:19 AM
| | Newbie | | Join Date: Feb 2006 Location: Live in California, yea sun!
Posts: 2
| |
As Tom Cahill would require, my challenge is (according to the "three
R's")
Reproducible: if run on OS 9.x, the monthly payment does not show up in
the text box:
Recognizable: I believe the Mac OS 9.x is not getting the temp_var
value returned to the var MP to show in the form. My hypothesis is
that the problems lies in this function: - function round_2(Number)
-
{
-
var temp_var = (Number.toFixed(2))
-
return temp_var
-
}
-
-
Repairable:I believe I've located the error location, but this is my
2nd day coding Javascript, so I don't know if it's repairable. Is
there a fix to this? I heard if the Number.toFixed method isn't
available on the operating system, it is possible to write that method
as a function.
Here's my code:
Thanks for your help
Last edited by KUB365; February 7th, 2006 at 02:14 PM.
| 
April 16th, 2008, 12:18 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,517
Provided Answers: 12 | | | re: Javascript in Mac: Number.toFixed challenge
You can add toFixed if it doesn't exist. Either use a function or add it directly using prototype, e.g. - if (!num.toFixed) {
-
Number.prototype.toFixed = function(precision) {
-
var num = (Math.round(this*Math.pow(10,precision))).toString();
-
return num.substring(0,num.length-precision) + "." + num.substring(num.length-precision, num.length);
-
}
-
}
| 
April 16th, 2008, 01:01 PM
|  | Moderator | | Join Date: May 2007 Location: Munich, Germany
Posts: 4,102
Provided Answers: 1 | | | re: Javascript in Mac: Number.toFixed challenge
and one more thing to mention: the problem is not the MAC ... it is the browser you would use with it that has to have an implementation of ECMA-Script ... and so the problem is the browser that is used with a specific OS ... and from that point of view the OS could be a problem when it limits the use of an up to date browser or the user who wants to use a specific browser that you have to support - but not the MAC itself :) ...
just this two cents from a MAC-user ... :)
kind regards
| 
April 16th, 2008, 01:57 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,517
Provided Answers: 12 | | | re: Javascript in Mac: Number.toFixed challenge
Yes, of course, you're absolutely right!
Forgot to mention that... thanks!
It's probably either IE5 on the Mac or an old version of Safari that's the problem.
| 
April 16th, 2008, 02:52 PM
| | Needs Regular Fix | | Join Date: Jun 2006
Posts: 425
| | | re: Javascript in Mac: Number.toFixed challenge
While acoder's method is flawless, and gits remarks apt, I am not sure that toFixed is the problem. I didn't remember the 'onfilter ' event, which is the one calling the method, untitl I googled it, Quote: |
onfilter is a non existent event handler that web based email services such as Yahoo mail uses in place of actual event handlers inside emails that contain a JavaScript. It's a security precaution, to disable any malicious script from executing in the user's browser.
| This doesn't mean he has the method toFixed, and anyone who doesn't can use acoder's replacement, but what event calls dosum?
| 
April 17th, 2008, 10:09 AM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,517
Provided Answers: 12 | | | re: Javascript in Mac: Number.toFixed challenge
Good spot! Goes to show that three (sets of) eyes are better than one... Quote: |
Originally Posted by mrhoo what event calls dosum? | Probably via the CALCULATE link at the bottom, though onfiltered should probably be onchange.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|