The NB variable does not get set. I inserted an alert box to see if I was generating the value properly and I am (the values entered into the form are shown in the alert box for each loop) but the nbSetVar command does not create/populate the NB variable in the NB app.

I have used window.external.nbSetVar and just nbSetVar. I have put the script in the header and in the body. These things are not the issue but I must have some syntax wrong.

I don't know why you don't have { } around the commands tp be serviced for each iteration in the for command ... and I don't know if the short form nbSetVar works.

But apart from that, the problem is most likely your use of 'formarray[i]' ... since you placed (the required) quotes around the parameter specification ... javascript will leave everything inside it 'as-is' ... so you end up asking to set a variable whose name includes the square brackets and the literal i... I do not believe you can have such 'NeoBook Variable Names'.

Thanks for commenting Gaev. When I simply have the alertbox in (remove the nbSetVar line) the script works correctly. It pops up the value of each element as it goes through the loop. I don't think the squiggly brackets is the issue. In fact, this script is based off a W3school sample.

My hope was to loop through the values and use the counter variable in JScript to also be the VariableArray number for NB.

I am wondering if it is expected usage with an in-page JScript function (called by jscript via a button) to set a NB variable as I tried to set an NB var with a static value and that does not appear to work either using either the short or full (window.external.nbSetVar) version of nbSetVar. I know this process works when I use a NB Function (of JS type). This is whats odd. I am relying on the NB debugger to tell me if the variable is created/populated. I am not seeing that happen in the debugger

dpayer wrote:Thanks for commenting Gaev. When I simply have the alertbox in (remove the nbSetVar line) the script works correctly. It pops up the value of each element as it goes through the loop. I don't think the squiggly brackets is the issue. In fact, this script is based off a W3school sample.

... the second alert only is executed one time: just when the loop end. This is the construction of the language, if you do not specify the brackets only the next instruction are executed, so, if we expect the two alerts we need to write something like this:

This makes me painfully aware that my jscript skills are elementary. David (DEC) thanks for the { } clarification of Gaev's comments. Dave (NeosoftSupport) thanks for the example. I had not seen the use of plus signs before in any example. Could you point me to a resource to understand how they are used and why they are needed in this case? I did not see them used in the W3Schools site. Is it a NB specific situation?

I cannot remember what article, tutorial or book (and for what language) tell me the use of the "brackets" or "blocks" in certain control structures. The only thing I can say about is that this is widely used, at the least, in the languages that I can know. But don't worry David, the exactly mistake are made (I'am sure, because I'am moderator of a Delphi forum from years ago) by many people, included me, of course. Some people always use the "brackets" or the appropiate "block" (like "begin" and "end") in order to prevent this kind of mistakes.

I had not seen the use of plus signs before in any example. Could you point me to a resource to understand how they are used and why they are needed in this case? I did not see them used in the W3Schools site. Is it a NB specific situation?

In Javascript you use plus signs to either add (numeric variables) or concatenate (string variables) e.g.

1) In my first post, I had neglected to check the Help file ... which clearly states that ...

The variable name should be surrounded by square brackets.

2) NeoBook Array Variables are just 'simple variables with a numeric suffix'

While NeoBook is kind enough to allow you to access elements of such array variables using syntax like [Name3] or [Name[x]] where x is another variable ... javascript is not so accomodating ... anything you specify within (single or double) quotes is passed 'as-is' ... hence the need to 'resolve the value of i on the javascript side.

@dec:

I did not know that you could skip the {} when you have 'just one command in the for loop' ... I always use such braces in all block commands ... if, else if, else, for, while, do etc. ... much easier to read/maintain as well.

I did not know that you could skip the {} when you have 'just one command in the for loop' ... I always use such braces in all block commands ... if, else if, else, for, while, do etc. ... much easier to read/maintain as well.

I agree. I almost always do the same thing, except on rare occasions, and for the two reasons: avoid this kind of "mistakes" and gain a better code readability.