Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Javascript replace function

Posted on 2006-03-21
1
Medium Priority
?
584 Views
Last Modified: 2012-06-27
Hello experts,

I am trying to get the current value of a textbox, add a new value to the original and assign the new total to the textbox. But unfortunately, in my textbox the original value is in the following form;

£100.00

So javascript is reading it as a string. Is there anyway I can strp the pound sign or force javascript to read it as a number

thankx
0
Comment
Question by:claracruz
1 Comment
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 total points
ID: 16246242
function poundsAsInt( textAmount )
{
    // Strip the "£" if it exists
    if( textAmount.charAt( 0 ) == '£' ) textAmount = textAmount.substring( 1 ) ;

    // return the number:
    return textAmount * 1.0 ;
}
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question