[thelist] javascript hacking
Warden, Matt
mwarden at mattwarden.com
Sun Jul 29 14:36:28 CDT 2001
On Jul 29, Dendymolz at aol.com had something to say about [thelist]...
>Is anyone familiar with the nopcart.js shopping cart script that is available
>free for download? I have zero knowledge of javascript, but am looking for a
>shopping cart that does't require a cgi for a couple of customers who don't
>need to accept credit cards. This one seems to work great, but I wonder if
>there is any big drawback to this kind of shopping cart.
>Also, I have managed hack the script so that it works for a German site, but
>I can't figure out how to change the "period" in the money tabulations into a
>comma. Germans (and much of the metric world) write money amounts like this:
>"10,00" instead of "10.00".
I'd imagine this is done automatically for browsers with the german
language (or other that uses a , rather than a .) set as the default, but
if you want to make this how it looks for everyone, you will have to find
the price variable and do something like this:
// first make sure that the price is rounded to the nearest cent
price = Math.round(price * 100)/100;
var sprice = price.toString();
var ilength = sprice.length;
var sDecimalMark = sprice.substring(ilength-3,ilength-2);
if (sDecimalMark == ",")
{
sFormattedPrice = sprice.substring(0,ilength-3)+"."+sprice.substring(ilength-2,ilength);
}
that should work (though it's untested).
thanks,
--
mattwarden
mattwarden.com
More information about the thelist
mailing list