0

I am new to JavaScript so would appreciate help on this issue I have.

I have a booking form I have made and I have 3 Eur results that come up automatically following the selection choices made (@Martina helped me with this challenge).

What I would like to do is get the results to show with 2 decimal places only - here is the link to the page I am talking about: https://www.alpinemalta.net/oilandgaslibya/bookNow.html

I've tried looking through some of the posts in this forum and attempted some of the things but my newness to JS has not helped :(

Thanks again in advance for any help on this.

Cheers - Chris Brown

Chris Brown
  • 15
  • 1
  • 6
  • @Alnitak - WOW - How simple - thank you so much for your speedy response - I need to add 3% to the amount and this is what I did: var pers3 = ((cost_E10.value*1.03).toFixed(2)) – Chris Brown Mar 22 '13 at 12:49

1 Answers1

1

The Number class in Javascript has a .toFixed method that does exactly what you require, e.g.:

var n = 234.1
var s = n.toFixed(2);  // s = "234.10"
Alnitak
  • 334,560
  • 70
  • 407
  • 495