numbers are missing when displayed on my website

  • Thread starter java script help needed
  • Start date
J

java script help needed

if the number is lets say, 1234 it shows as 12.34
that ok but if it was 12.30
it only shows 12.3

how do I get it to show the whole number

the line that displays this number is


form.total.value = "£"+(Math.floor(ctotal)/100)+"p";



thank you in advance for your help

Jason
 
S

Steve Easton

Try using a different math method math.floor returns the greatest integer less than or equal to its
numeric argument
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsmthfloor.asp

Additionally you don't have to call the math object in your script as it is automatically available.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsobjmath.asp

Have you tried using the eval method?? It may take some tinkering

form.total.value = "£"+(eval(ctotal)/100)+"p";

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
J

java script help needed

i have tried
form.total.value = "£"+(eval(ctotal)/100)+"p";
form.total.value = "£"+(eval(ctotal/100))+"p";

both show the same as the old one i have used, still the decimal point is
there but the zeros at the end are not shown.

still shown like £1.9p instead of £1.90p

looked at the microsoft site but all command are for Fox Pro or something??

any other ideas how to get the demical point and the zeros there?

thanks


Jason
 
J

java script help needed

just in case anyone else wants to know i found out how to get the total
figure to show as 12.30 and not 12.3

new function added in the javascript part of your html script



function adddecimal(amount) {
// returns the amount in the .99 format
amount -= 0;
return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10
== Math.floor(amount*10)) ? amount + '0' : amount);
}

now the correct number/value is shown
 
M

MD Websunlimited

Hi,

The function is working as designed. If you wish to display a currency amount you'll have to use the a function to format value.

function cent(amount) {
// returns the amount in the .99 format
amount -= 0;
return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top