Hey Everyone, I have a small piece of JS that updates a number inside of a div, it works great - until the number reaches 1,000 and a comma is added. Can anyone help with the code to fix this issue? I have tried quite a few option but everyone of them breaks the script. <script> function UpdatePoints(id,math) { jQuery.ajax({ type: "POST", data: {number_id: id, math: math}, url: "http://localhost/top10/parts/vote.php", cache: false, success: function(response) { if (math == 1) { $('#p'+id).html(function(i, val) { return val*1+1 }); $('#point-up-'+id).hide(); $('#point-down-'+id).hide(); $('#vote-up-'+id).css('display','block') } else { $('#p'+id).html(function(i, val) { return val*1-1 }); $('#point-up-'+id).hide(); $('#point-down-'+id).hide(); $('#vote-down-'+id).css('display','block') } } }); } </script> Code (JavaScript): It is this line that's not working, all it is doing is grabbing the value and adding +1 (or -1 on the bottom half). $('#p'+id).html(function(i, val) { return val*1+1 }); Code (JavaScript): Any help would be greatly appreciated!!
In the JS I am not, it is pulling a number from a database and the PHP is adding the comma, works great until the number needs a comma.
It does seem like the easiest solution - however on page load without the php adding the comma it just says 1000, they they have to click to run the JS and update the number.
Remove the comma when you ENTER your function. If you need the comma in the result, add it back BEFORE leaving the function.