/    Sign up×
Community /Pin to ProfileBookmark

If tofixed() doesn’t work on Mac browsers, what is an alt method for money formatting

HI, i was using a script dynamically update an order form,and i was using onchange, then in the function i was using tofixed(), but in this thread, it says that tofixed doesn’t work in Mac browsers, so im looking for another solutions, thanks for any help in advance.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonSep 22.2005 — Just define a .toFixed yourself, like so:Number.prototype.toFixed = function(places){

var temp = ( Math.round( this * Math.pow(10,places) ) ).toString();

return temp.substring(0,temp.length-places) + "." + temp.substring(temp.length-places, temp.length);

}

alert((1234.5678).toFixed(2));
Copy linkTweet thisAlerts:
@decibelauthorOct 17.2005 — if i define toFixed in my script, it wont mess up the toFixed already in javascript? sorry for the newb question.
Copy linkTweet thisAlerts:
@JonaOct 17.2005 — [font=trebuchet ms]Check for its existence.[/font]

<i>
</i>if(!Number.prototype.toFixed){
// code;
}
Copy linkTweet thisAlerts:
@decibelauthorOct 17.2005 — thanks guys, your all geniouses!!!
×

Success!

Help @decibel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...