This topic is locked

Entering Currency in a Form

6/18/2006 9:58:33 PM
PHPRunner General questions
R
renegadekn author

I am having an issue when entering currency in a form built by phprunner.

I enter 125,000 and it stores 125.00 in the database. I know this is probably an issue with the comma, but is

there a work around so the user can enter either $125,000 or 125,000 and have the correct amount stored?
As always, thanks,
-Rob

Alexey admin 6/19/2006

Rob,
you can adapt the user-entered currency values before putting them to the database.

Modify generated ..._add.php and ..._edit.php files for this.

Find this snippet there:

$value=postvalue("value".$akey);

$type=@$_POST["type".$akey];

and put the following just after:

if($field=="CurrencyField")

{

if(substr($value,0,1)=="$")

$value=substr($value,1);

$value=str_replace(",","",$value);

}



where CurrencyField is your actual field name.