Solution 1 :

put dinamic value in a [] quotes instead .

console.log(document.calculate[$(this.count)].value);

Solution 2 :

for (let i = 1; i<=2; i++) {
  let count = String("q" + i);
  console.log(document.calculate.$(this[count]).value);
}

Problem :

Currently I’m trying out some html and js stuff.
I have trouble using a changing string inside a command with some “.” in it.

for (let i = 1; i <= 2; i++) {
    let count = String("q" + i);
    console.log(document.calculate.$(this.count).value);
}

So the String “count” is changing and I want the different values of my document with the names “q1”, “q2″…

Would be awesome if someone could help me.
Thank You!

Comments

Comment posted by “bracket notation”

“bracket notation”

Comment posted by Pad_

Thanks. That worked 🙂

By