G
G
German_Berg2019-11-01 10:56:50
Node.js
German_Berg, 2019-11-01 10:56:50

How to add number 1 to number in txt file?

There is a script:

var number1 = 0;
function plus1() {
  var count1 = document.getElementById('count1');
  number1++;
  count1.innerHTML = number1;
  txt_1();
}
function txt_1() {
fs1=require("fs")
fs1.writeFileSync("file/text_1.txt", number1,  "ascii")
}
$.ajax({
      url: 'text_1.txt',
      success: function(data) {
     document.getElementById('count1').innerHTML = data;
      }
});

Which, when calling the plus1 function, adds +1 to the number in the file, but the problem is that instead of somehow you need to specify the file where these numbers are stored. It should look something like this: . var number1 = 0;
var number1 = txt.txt;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pashenka, 2019-11-01
@like-a-boss

No, you need a Jaquery here...

spoiler
тыцQ3mkcnl.gif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question