Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2003, 07:24 PM
Registered User
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript Calculator - Help!

If this has been posted before, I apologize. I have a javascript calculator on my pages. What I want to do, is have the price automatically appear in the price field, but it won't calculate because there is a "$" and a "," in the field.

Is there ANY possible way to remove the "$" AND the "," either on page load or before the calculation? Or better yet, can you tell javascript to ignore the "$" and ","?

I know in PERL, you can use a slash... is there something like that in javascript?

Here's one of the pages where the calculator is located:
http://www.collectorcarsforsale.com/...ngs/l0002.html

Any help would be greatly appreciated.

Thanks!
Scott


 
Old November 16th, 2003, 11:13 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can easily search for the $ and , and remove them before you try to do calculations. I beleive the syntax would be something along these lines:

nPrice = priceField.value.replace("$","").replace(",","")

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
calculator mojtaba rashidi Visual Studio 2005 0 March 17th, 2008 07:29 AM
Calculator DweeLer Other Programming Languages 1 November 18th, 2005 08:13 AM
Javascript for an alphanumeric calculator gilgalbiblewheel Java GUI 0 September 13th, 2004 11:37 AM
calculator kale_tushar C++ Programming 1 January 28th, 2004 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.