views:

47

answers:

1

I have a form field that uses some Javascript to format user input 'price' field from say 1000 to 1,000.00 in real time before the form is submitted ..when I submit the form some PHP is reading the data and printing the results

Javascript bit is num = num.substring(0,num.length-(4*i+3))+','+

PHP bit is 'price' => number_format($this->ipsclass->input['price'], 2, '.', ''),

The problem is if the preformatted Price is 2,450.50 ..all it displays 2.00 or if the input is 24,500 displays 24.00

if works fine if I remove the ',' from the javascript The database field has a data type float 9,2 cause I need to sort search results

+2  A: 

Remove the comma yourself:

number_format(str_replace(",", "", $this->ipsclass->input['price']), 2, '.', '')
Artefacto
thanks! Works perfectly
you could accept the answer then :p
Artefacto
sorry for the delay in accepting