Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why is JS not showing my 0(zero) values in text box!?! 1

Status
Not open for further replies.

hpadwal

Programmer
Feb 6, 2006
57
GB
hello all,

I have recently created the following JS wich works perfectly except it is not showing the 0 (zeros) values in the targeted text box.

For example a 0.00 value does not show nothing and 13.50 shows as 13.5

can you help?

here is a sample of my code

Code:
if (prempack == 4) 
    {
        premsum = 20.00;
    }
    thisform.premoutput.value = premsum;

and text box
Code:
<input type="text" name="premoutput" size="4" readonly="true"/>

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

- Doh

 
You need to use the toFixed method:
[small](passing the number of decimals as the argument)[/small]
Code:
<script type="text/javascript">
var a = 1.10;
alert("normal: " + a + "\ntoFixed: " + a.[!]toFixed(2)[/!]);
</script>

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top