Page 1 of 1
Formatting Numeric Values in Input
Posted: 2014-06-01 03:43
by energylevels2012
Doesn't seem to be a built in way to handle how numbers are displayed/formatted in ADDT?
I have a numeric value want to display in input field with thousand comma separators like 10,000 .... can format value for display in php number_format() for display but how then how do you clean the value before inserting into mysql again?
Re: Formatting Numeric Values in Input
Posted: 2014-06-01 09:37
by Fred
A bit of hand coding will do the trick.
Refer to this article as a starting point
http://www.interaktonline.info/article/ ... email.html
Then your code will be something like this
Code: Select all
$string = str_replace(',', '', $string);
Re: Formatting Numeric Values in Input
Posted: 2014-06-02 03:46
by energylevels2012
Thanks sorted
Code:
//start Format_Prices trigger
function Format_Prices(&$tNG) {
$tNG->setColumnValue("Cost_Price", trim(str_replace(',','',$tNG->getColumnValue('Cost_Price'))));
}
//end Format_Prices trigger
Trigger 'BEFORE' code for insert and update in appropriate sections:
$ins_valuations->registerTrigger("BEFORE", "Format_Prices", 50);
$upd_valuations->registerTrigger("BEFORE", "Format_Prices", 50);
Input field with number formatted with thousands comma separator:
<input type="text" name="Cost_Price_<?php echo $cnt1; ?>" id="Cost_Price_<?php echo $cnt1; ?>" value="<?php echo number_format($row_rsvaluations['Cost_Price']); ?>" size="10" />