T
T
twentytvvo2019-12-29 01:30:01
JavaScript
twentytvvo, 2019-12-29 01:30:01

How to get a certain line from another site and set a variable in js to it?

Such JS, from here you need https://bank.gov.ua/NBUStService/v1/statdirector... pull up <rate> and you need in the line

var payment = (( w * 1 ) + ( h * 1 ) + ( t * 1 ) + ( p * 1 ) + ( m * 1 )) * r || 0;
so that r is that number from the string.
var calculator = new Vue({
  el: '#calculator',
  data: {
    width: '',
    height: '',
    position: '',
    tradeIn: '',
    mark: '',
    calcPayment: ''
  },
  computed: {
    calcPayment: function(e){
      var w = this.width;
                        var h = this.height;
      var p = this.position;
                        var t = this.tradeIn;
      var m = this.mark;
      var payment = (( w * 1 ) + ( h * 1 ) + ( t * 1 ) + ( p * 1 ) + ( m * 1 )) * r || 0;
      return currencyFormat(payment);
    },
    numFormat: function(e){
      e.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
    }
  }
  
});


//https://blog.tompawlak.org/number-currency-formatting-javascript
function currencyFormat (num) {
    return "" + num.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Karpion, 2019-12-29
@Karpion

Probably load the entire page into a variable, then parse it for the desired field.

S
sashabeep, 2019-12-29
@sashabeep

https://lmgtfy.com/?q=vue+parse+json+from+remote+server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question