Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Javascript 

Convert something loaded from website to an int and multiply

So, I want to put that in a variable (var total_rece_btc), the load part, where it is being converted to an INT and multiplied by 0.00000001
Code
$('#total_received_btc').load('https://blockchain.info/q/addressbalance/' + '1EzwoHtiXB4iFwedPr49iywjZn2nnekhoj' + '?confirmations=0');

Thanks in advance  🤝
Does that page return a string or something?

Do:
Code
parseInt(total_rece_btc) * 0.000001

I'm not sure why you're using .load to get the variable. Do this instead:
Code
$.get('https://blockchain.info/q/addressbalance/' + '1EzwoHtiXB4iFwedPr49iywjZn2nnekhoj' + '?confirmations=0', function(d) {
      $('#total_received_btc').text(parseInt(d) * 0.00000001);
});
Side note: So I don't get chastised, you should probably throw a check to make sure the page returns a parsable string/int. Otherwise the text for #total_received_btc will end up being something like "undefined" or "not a int" or like "false" and that's obviously a problem for you and your users.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
(Mar 1, 2018 02:19 PM)Nachfolger Wrote:  Does that page return a string or something?

Do:
Code
parseInt (total_rece_btc) * 0.000001

Tried this thing, wont work:
Code
var total_received_btc = parseInt(load('https://blockchain.info/q/addressbalance/' + '1EzwoHtiXB4iFwedPr49iywjZn2nnekhoj' + '?confirmations=0')) * 0.000001;
                  $('#total_received_btc').html(total_received_btc);
(Mar 1, 2018 02:29 PM)Konstantinos Wrote:  Tried this thing, wont work:
Code
                 var total_received_btc = parseInt(load('https://blockchain.info/q/addressbalance/' + '1EzwoHtiXB4iFwedPr49iywjZn2nnekhoj' + '?confirmations=0')) * 0.000001;
                 $('#total_received_btc').html(total_received_btc);
What even are you doing. I just told you how to do it.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
(Mar 1, 2018 02:29 PM)Nachfolger Wrote:  What the fuck are you doing. I just told you how to do it.

Sorry, I forgot to check your edited post and edit my own as well, your code worked, thanks 🤝


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by LanteJun 4, 2019 12:58 PM 4 189 Jun 4, 2019 12:58 PM
Last Post: cash0me
[PHP] by PDGLOBALMar 28, 2018 01:15 AM 4 131 Mar 28, 2018 01:15 AM
Last Post: PDGLOBAL
[PHP] by LockheedMar 23, 2018 07:11 AM 9 219 Mar 23, 2018 07:11 AM
Last Post: Charger