I need to remove the comma in order to send the variable in javascript and work the number to 1200> 1.2K. The problem is that javascript takes the comma as if it were sending 2 values and only works with numbers without a comma.
So what I need is to remove the comma before sending it to javascript.
Example:
1,000 > 1000
1,000,000 > 1000000
PHP Code:
<script type="text/javascript">
function fHcountHits(num) {
if (num >= 1000000000) {
return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'G';
} else if (num >= 1000000) {
return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
} else if (num >= 1000) {
return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
}
return num;
}
</script>
PHP Code:
<script type="text/javascript">document.write(fHcountHits({vb:raw forum.threadcount}));</script>
<script type="text/javascript">document.write(fHcountHits({vb:raw forum.replycount}));</script>
The error is that the {vb:raw forum.threadcount} and {vb:raw forum.replycount} return the numbers with a comma, how do I remove them ?.
thx