Page 1 of 1

Adding up values with $ signs

Posted: Mon May 12, 2003 2:37 pm
by Templeton Peck
I have a form with text fields where $ amounts get entered.. like say $5 but when it hits the target php file to total and display the amount. If there are any "$" signs used in the text field on the form it comes out blank in the target php file and doesn't total it. Anyway I can fix this so it'll just ignore the $ sign and add the value beside it?

thanks :)

Posted: Mon May 12, 2003 4:17 pm
by twigletmac
If the amounts are always going to be in dollars then just put the dollar sign in the form next to the text field and just take numerical input in the text field. You can also strip the $ sign out before doing the calculations:

Code: Select all

$no_dollar = str_replace('$', '', $with_dollar);
and put it back when you're finished.

Mac