-2
function test(art) {

        document.formular.eval(art+"_name").value =  "Test";
} 

This gives an eval is not a function error.

I tried document.formular.[art+'_name'].value = "Test";
Which won't work either.

NoviceProgrammer
  • 3,347
  • 1
  • 22
  • 32
Tom Senner
  • 111
  • 9
  • check `formular` documentation for `eval` method. It looks like there is no such function in this object. You're probably confusing it with javascript's native `eval()` – Ejaz May 22 '14 at 13:01
  • If at all, it would be `eval('document.formular.'+art+'_name.value = "Test"')`, but [that's an incredibly bad idea](http://stackoverflow.com/questions/86513/why-is-using-the-javascript-eval-function-a-bad-idea) – Bergi May 22 '14 at 13:02

1 Answers1

4

Try:

document.formular[art+'_name'].value =  "Test";
Getz
  • 3,983
  • 6
  • 35
  • 52