PDA

View Full Version : strip commas problem


jay
10-06-2009, 01:02 PM
Hi

I'm using JavaScript to add commas to a price field in my website, then php strip commas to remove them before feeding the database.

The field in the database is set to int.

Every time the value is fed into the db only the digits up to the comma is inserted not the all the digits.

Example:

100,000 is fed as 100 and 10,000 is fed as 10

I believe its because the ',' is converted to a ''(space) and then the browser thinks its the end of the value entered.

Here's the code:

<input type="text" name="price" id="price" onkeyup="format(this)" onchange="format(this)"
onblur="if(this.value.indexOf('.')==-1)this.value=this.value" value="<?php
echo str_replace("," ,"",($row_rsseller['price'])); ?>" size="32" />


Thanks in advance

jay
10-06-2009, 04:36 PM
the strippers have been contained