/    Sign up×
Community /Pin to ProfileBookmark

Need help with javascript output

I have a form with the following calculation (partly):

//AdWords – Calculatie Aantal Klikken
var aantal=document.getElementById(‘aantal_klikken’);
aantal.value=0;
aantal.value=parseFloat(aantal.value);

if(op16.value==1) aantal.value=(parseFloat(op14.value)-parseFloat(op14.value)*0.2*parseFloat(op16.value))/(parseFloat(op15.value)*0.7);

I need to have the output in 2 digits, but I can’t get it to work.

Anyone got an Idea how to fix this?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@PadonakMay 11.2012 — toFixed()
Copy linkTweet thisAlerts:
@OebidoebieauthorMay 11.2012 — toFixed()[/QUOTE]

Thanks for the quick response.

As I'm just starting out with javascript, can you give me an example how I can add it to my script?

I tried it myself, but I can't get it to work.
Copy linkTweet thisAlerts:
@PadonakMay 11.2012 — i think that would be something like:

[CODE]if(op16.value==1){
aantal.value=((parseFloat(op14.value)-parseFloat(op14.value)*0.2*parseFloat(op16.value))/(parseFloat(op15.value)*0.7)).toFixed(2);
}[/CODE]
Copy linkTweet thisAlerts:
@OebidoebieauthorMay 11.2012 — Thanks.

Life can be so simple :-)
Copy linkTweet thisAlerts:
@PadonakMay 11.2012 — the more you uncover the more remains hidden ))
×

Success!

Help @Oebidoebie 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...