Author Topic: Display Prices with correct notation  (Read 12901 times)

0 Members and 1 Guest are viewing this topic.

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Display Prices with correct notation
« on: March 26, 2007, 03:03:14 PM »
OK, admittedly this is for the US users, but I'm sure it could be adapted for the European users.  This script will allow you to take a field that you denote for currency and make sure the proper denomination sign is displayed:

Code: [Select]
<script>
var price="[[price]]"
if (price>=1.00)
{
document.write("$[[price]]")
}
else
{
document.write(price.substring(1) + "")
}
</script>

Basically, it reads your DB field, determines if it is dollars or cents, then properly displays either the $ or sign.  As well, it lops off the decimal if it is in fact cents.  This could be adapted for other currencies I'm sure.  Hope this is useful!

Jason
Founder of www.slipdex.com