admin管理员组文章数量:1277271
thanks for looking my questions, I can't find the way to remove the ma with javascript. So I have problem at removing ma from page with java-script, Adding Comma for output is fine i guess, but for removing ma for value, the function is not working for me.
The source code is : /
Please let me know, thanks again.
thanks for looking my questions, I can't find the way to remove the ma with javascript. So I have problem at removing ma from page with java-script, Adding Comma for output is fine i guess, but for removing ma for value, the function is not working for me.
The source code is : http://jsfiddle/Q5CwM/2/
Please let me know, thanks again.
Share Improve this question asked Oct 20, 2011 at 22:08 XML guyXML guy 3994 gold badges6 silver badges16 bronze badges 3- 2 What is your question? Where are you trying to remove the ma from? Looking at your jsFiddle and there's no ma on your number output. – Jonathon Bolster Commented Oct 20, 2011 at 22:12
- checkNumeric() function is removing the ma, Comma() function is adding the ma. If you see this -> jsfiddle/Q5CwM/1/ that page doesn't have ma at all. But I want to add ma for display. So I add the ma function and use at line 69 for adding ma. And I tried to use removing ma at line 66. When i use that removing ma function, the page is having error of NaN. – XML guy Commented Oct 20, 2011 at 22:15
- checkNumeric was removing the mas and then doing nothing with the result, thus nothing was changing. See my answer below for how to fix it. – jfriend00 Commented Oct 20, 2011 at 22:19
1 Answer
Reset to default 6I have no idea what your code is trying to do overall, but you can fix this function that removes mas:
function checkNumeric(objName) {
var lstLetters = objName;
var lstReplace = lstLetters.replace(/\,/g,'');
}
by changing it to this:
function removeCommas(str) {
return(str.replace(/,/g,''));
}
You weren't returning the changed string from the function and I changed the name of the function and parameters to represent what it does.
str.replace
returns the changed string. It does not change the string you started with so in order to do something with the result of the replacement, you have to either return that from the function or assign it to some other string. As you had it, nothing was happening with the replaced string so the function did nothing.
本文标签: Removing comma for value with JavascriptStack Overflow
版权声明:本文标题:Removing comma for value with Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741276186a2369740.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论