Joerg Heinicke <j.heinicke <at> ewerk.com> writes: > 05: var formtype = cocoon.parameters["formtype"]; > ... > 19: var functionName = "display" + formtype; > 20: print(functionName); > 21: var function = this[functionName]; > > SyntaxError: missing variable name > (file:/C:/Projekte/cocoon-2.1/build/webapp/samples/erak/flow/form.js; > line 21) > > The print in line 20 is not executed, another print before writing just > 'starting form handling' is neither, so it's something like preparsing. At > that time functionName is of course not available. Changing the above line > 19 - 21 to just var function = this["display" + formtype]; works. Can you > tell me why?
*argh* I had the idea 30 seconds after writing it: function is a preserved word. What I had yesterday working was not var function = this["display" + formtype]; but this["display" + formtype].apply(form, args); directly. Sometimes one should simply copy & paste code and not try to beautify the code ... Joerg
