mercredi 26 juin 2019

I wish to know how do we set session with function instead of assigning values

How do I fix these random values so that it remains the same till 12 hours. This is getting changed each time the page is refreshed.

This is my code assigning random numbers to a section

function getRandomNumber(minNumber, maxNumber) {
  return Math.floor(Math.random() * (maxNumber + 1) +
    minNumber);
}

getRandomNumber();

$('.someclass').each(function() {
  var x = $(this);
  const y = $(.sproof); //sproof is the snippet where the value 
  is being inserted //
  y.insertAfter(x.find('.someclass2'));
});

$('.someclass3').each(function() {
  var minNumber = 700;
  var maxNumber = 701;
  $(this).html(getRandomNumber(minNumber, maxNumber));
});

$('.someclass3').each(function() {
  var minNumber = 700;
  var maxNumber = 701;
  $(this).html(getRandomNumber(minNumber, maxNumber));
});

The random number needs to be the same throughout the day even after refresh. My case is that the numbers are generated each time the page is refreshed.




Aucun commentaire:

Enregistrer un commentaire