0

I have a popup form and need to return a value to the master form. The first statement works fine, but when I try to put the field name (textAlert) to a variable, I cannot get it to work. I tried all kinds of syntax. Please help. Thanks.

function DoReturnValue() 
{
    opener.MasterForm.textAlert.value = "Hello";     // WORKS

    /*   DOES NOT WORK
    var theField = "textAlert";
    opener.MasterForm(theField).value = "Haloha";
    opener.document.MasterForm.getElementById(theField).value = "Haloha";
    */
}
pushkin
  • 9,575
  • 15
  • 51
  • 95

1 Answers1

0

To access properties dynamically with a string variable as a name, use square-bracket notation:

opener.MasterForm[theField].value = "Haloha";
VisioN
  • 143,310
  • 32
  • 282
  • 281