0

I need help, how to insert variable n as XX. Variable n is number, for example 3 and I need to get this number to document.form1.any3.value; is it possible? Thanks for advice

function pokus(n){
    var any1 = document.form1.anyXX.value;
}
user2374693
  • 163
  • 1
  • 2
  • 10

1 Answers1

7

Use square bracket notation:

function pokus(n){
    var any1 = document.form1['any'+n].value;
}
George
  • 36,413
  • 9
  • 66
  • 103