javascript - Passing array of array elements to a function -


I'm searching for answers to this concept all day and left it eventually and decided to ask it here.

I have the concept:

I have a set of plains, which are arrayed, I want the area set to be inside the array so that I use a standard function You can do so on the basis of the fields included in the module and one more paramount to check.

Sample code:

module1.php

  & lt ;? Php $ i = 0; While ($ i <5) {? & Gt; & Lt; Input type = "text" name = "field 1 [$ i]" /> & Lt; Input type = "text" name = "field2 [$ i]" /> & Lt; Input type = "text" name = "field3 [$ i]" /> & Lt ;? Php $ i ++; }? & Gt; & Lt; Input type = "button" name = "process" onclick = "checkFields (['field1', 'field2', 'field3'], 'module1');" / & Gt; & Lt; Script & gt; Function Checkfield (F, M) {var fn = f.length; Warning (FN); // output is for 3 (i = 0; i  

So, with that comment, that part is, how can I not understand this, I use getElementById , getElementsByName Tried, but it is not working.

Or is there any possibility that I can cross a limit of elements like this: array (field1, field2, field3) at a function?

Edit: I added a loop statement to make the concept even more comprehensive.

  & lt; Script & gt; Function Checkfield (F, M) {var fn = f.length; Warning (FN); {Var nfn = f [i] for (I = 0; i & lt; = fn; i ++). Length; // This is where this warning is not working (NFN); }} & Lt; / Script & gt;  

You should implement the indexer on F parameter instead of the FA variable, which is an integer.


Comments