Hi,

I have created a page that displays foreign exchange rates with 6 decimal places, such as GBP 1.654321 and I want to display only 4. The code that Iíve added is shown below, but it does not have any effect on the resulting display.

Thanks.

//added to format decimal places
pushtable.onChangingValues = formatValues;

//copied from StockListDemo
//WDX is name of field in schema that requires formatting
function formatValues(item, itemUpdate) {
if (itemUpdate == null) return;
var newValue = itemUpdate.getFormattedValue("WDX");
if (newValue != null) {
var formattedVal = formatDecimal(newValue, 4, true);
itemUpdate.setFormattedValue("WDX",formattedVal);
}
}


// format a decimal number to a fixed number of decimals
function formatDecimal(value, decimals, keepZero) {
var mul = new String("1");
var zero = new String("0");
for (var i = decimals; i > 0; i--) {
mul += zero;
}
value = Math.round(value * mul);
value = value / mul;
var strVal = new String(value);
if (!keepZero) {
return strVal;
}

var nowDecimals = 0;
var dot = strVal.indexOf(".");
if (dot == -1) {
strVal += ".";
} else {
nowDecimals = strVal.length - dot - 1;
}
for (var i = nowDecimals; i < decimals; i++) {
strVal = strVal + zero;
}

return strVal;
}