ColdFusion float problems

coldfusion, javascript

Solution

The reason is that when you're outputting the content into the "value" you're basically rendering HTML.

What that means is that your numeric values are being "converted" into a string representation when CF is generating the HTML.

Check out the NumberFormat function here which will allow you to tell CF how to output the content rather than it trying to do a "best guess"

<tr colspan="2">
        <td class="tdDescription"> Rate Per Hour </td>
        <td><input type="text" name="Rate" class="inputText350" <cfif getHourlyForm.Rate neq ""> value="#NumberFormat(getHourlyForm.Rate,"9.99")#"</cfif>/></td>
</tr>

Problem

Im trying to make my program to show two decimals points but it keeps dropping the zero, so if I have `140.00` it shows as `140.0`, but if I do `140.15` it will show `140.15`. However, for some reason it will always drop the zero. Here is the code I think that needs editing. Any help would be appreciated. ``` <cfinput type="Text" name="HourlyRate" value="0.00" required="Yes" validate="float" message="A Default Hourly Rate is required...." class="inputText200" size="8">** ``` or here ``` <input type="text" name="Rate" <cfif #getHourlyForm.Rate# neq ""> value="#getHourlyForm.Rate#"</cfif> /> ```

Original source