-3

I have the below code and i want to replace the code at run time depending on a variable value, how do i achieve this using javascript. Also please ignore the FormA , animate etc as they are used by kony mobile.

//desired out put inside the run time code. 
    FormA.ItemFlexContainer0.animate

    //index has a value of 0 for now. 
    var index = 0;
    var ItemFlexContainerString = "ItemFlexContainer"+index;
    FormA.ItemFlexContainerString.animate

    Error :- Type Error null is not an object 

Since ItemFlexContainerString doesnt exist it will throw the error.

Max
  • 5,380
  • 6
  • 42
  • 66
  • in my case this worked and the answer mentioned in the existing question would not work, FormCart["ItemFlexContainer"+index].animate , the array should have double quotes with index appended to it as written. – Max Feb 19 '16 at 16:41

1 Answers1

0

You need bracket notation:

FormA[ItemFlexContainerString]animate
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964