0

Hey everyone looking for a bit of help adding a .toFixed to a variable in jquery.

< script type = "text/javascript" > $(document).ready(function() {
  var a = $("#address").text();
  $.get("http://99.236.215.227:7379/hget/Pool_Stats:CurrentShift:WorkerBTC/" + a + ".txt", function(b) {
    $(".payout").text(b)
  });

  $.get("http://99.236.215.227:7379/hget/Pool_Stats:CurrentShift:WorkerNEOSCoin/" + a + ".txt", function(b) {
    $(".payout2").text(b)
  });
  $.get("http://99.236.215.227:7379/hget/Pool_Stats:CurrentShift:WorkerFUELCoin/" + a + ".txt", function(b) {
    $(".payout3").text(b)
  })
});
$(function() {
  var a = $("#address").text();
  $.get("http://99.236.215.227:7379/ZSCORE/Pool_Stats:Balances/" + a, function(b) {
    $(".owed").append(b.ZSCORE)
  })
}); < /script>
Infernoman
  • 33
  • 8
  • sorry i guess i should've specified a bit better. each of the payout variables are numbers which are gathered from the links. currently im having the formatting issue on my website http://infernopool.com/miner/1nfernow9yCJGQN6RxvpA13y9HjNGvgDw each of the payout variables is what im trying to add .toFixed(8) to. – Infernoman Feb 28 '15 at 03:27

1 Answers1

2

So convert it to a number and apply toFixed(8)

parseFloat(b).toFixed(8)

so since you do not know how text() works, the line should be

$(".payout2").text(parseFloat(b).toFixed(8))
epascarello
  • 204,599
  • 20
  • 195
  • 236
  • so as an example $.get("http://99.236.215.227:7379/hget/Pool_Stats:CurrentShift:WorkerBTC/" + a + ".txt", function(b) {$(".payout").text.parseFloat(b).toFixed(8) – Infernoman Feb 28 '15 at 03:32
  • That is not how text() works. Replace the b in your original with my line. – epascarello Feb 28 '15 at 03:35
  • so instead of function(b) using the parsefloat method? $.get("http://99.236.215.227:7379/hget/Pool_Stats:CurrentShift:WorkerBTC/" + a + ".txt", parseFloat(b).toFixed(8) {$(".payout").text(b) – Infernoman Feb 28 '15 at 03:37
  • Thanks for your help. im not very experience with java. and im just working with what i have. i was originally just using the .tofixed method and wouldve been why i was having problems – Infernoman Feb 28 '15 at 03:43
  • Heh. I know there is a difference between them in my head. but expressing them as different things is tricky. since im always looking for the shortest form. Once again thank you for the help. – Infernoman Feb 28 '15 at 03:49