Jump to content

Recommended Posts

Hello All!

 

I'm working on something that isn't quite working right yet and am hoping someone out there can help me with it.

 

Currently, if the user enters a list_price value of 25,000, my program is changing it to 25; if I enter 25000 (w/o the comma), it's displaying OK, but I'd like to be able to put the comma in the field.

 

What do I need to change/add to accomplish this?

 

Here's my code for it:

 

 

<tr>

  <th>List Price</th>

    <td>

      <input type=text name='list_price' size=9 value='<?=htmlentities($property->getListPrice(), ENT_QUOTES)?>'>

    </td>

</tr>

 

 

and my 'getListPrice' function:

function getListPrice()
{
   return($this->data["list_price"]);
}

 

If I need to supply any additional info, please let me know.

 

Thanks in advance for your time and expertise!!

 

-j.g.

Link to comment
https://forums.phpfreaks.com/topic/66221-newbie-number-format-questin/
Share on other sites

Well, I'm a little bit closer I think; I changed my getListPrice function to:

 

function getListPrice()
  {
    //return($this->data["list_price"]);
    return number_format($this->data["list_price"], 0, "", ",");
  }

 

and, it's putting the comma in there if the user enters 80000 (output is 80,000) --- However, if the user puts a comma into this field ex: 80,000, it's still returning 80.

 

Any ideas? I'd like them to be able to input the comma...

 

Thanks much!

-j.g.

Well, this function is still returning $80.00, even though 80,000 is in the db -- I'm assuming it has to do w/ the non-numeric comma, as just pointed out...

 

What do I need to change to get the $80,000.00 output instead of $80.00?

 

function format_money($dec, $prefix='$')
{
  return("$prefix".sprintf("%01.2f",round($dec, 2)));
}

 

Any ideas?

-j.g.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.