How to display decimal
for input text taken from a database, onload in JavaScript.
Am having value as 100
when displaying it from the database into a text box. It should be 100.00
. Is it possible.
How to display decimal
for input text taken from a database, onload in JavaScript.
Am having value as 100
when displaying it from the database into a text box. It should be 100.00
. Is it possible.
Javascript
function onclick(id)
{
document.getElementById('text').value = id.toFixed(2);
}
you can set 100
as 100.00
using php
<input type="text" value="<?php echo number_format($row['numbert'],'2','.',''); ?>" />
You can use to toFixed javascript function:
var x = 100;
document.getElementById('textbox').value = x.toFixed(2);