Question: I want to set some variables getting they from the values of 5 select elements, the multiselect IDs have the same name that the variable names in the script....

Inside HTML part:

```
  <select id="variable1">
    <option value="10">10</option>
    <option value="20">20</option>
    <option value="50">50</option>
  </select>

  <select id="variable2">
    <option value="algo1">algo1</option>
    <option value="algo2">algo2</option>
    <option value="algo3">algo3</option>
  </select>

  <!-- etc -->

```

and in the jQuery script:

```
  var variable1;
  var variable2;
  var variable3;
  var variable4;
  var variable5;
  $("#variable1, #variable2, #variable3, #variable4, #variable5").change(function(){
    var valorAcambiar = $(this).attr('id');
    valorAcambiar = $(this).val();
  });

```

So I'm trying this, but doesn't work... I think the problem is that the script is not running the selected strings values from the ID attr of the select elements as variable names for the script, some one could please help me?

I mean, I want that "valorAcambiar" takes the name of variable1 (coming from id attr of select element) or any other, to change global variable1 (or any other) value in the script.

So I can get variable1 = 20 for example if someone changes variable1 select, or variable2 = algo3 for example if someone changes variable2 select, and this for the 5 multiselect elements.

Thanks.

Answer: 
Use a setInterval and set it to one **second** => `1000`

```js
let display = document.getElementById('display')
let x = display.textContent;
// textContent returns a string value

setInterval(()=>{
  // lets change the string value into an integer using parseInt()
  // parseInt would not be needed if the value of x was `typeof` integer already
  display.textContent = parseInt(x++)
}, 1000)
```

```html
<div id="display">2</div>
```
You can use javascript setInterval function <https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval>

For example:

```
var x = 0;

setInterval(() => {
  x = x + 1;
}, 1000); //1000ms = 1 second

```

Then each second it will increment the "x" variable.