looping in javascript -


As the code below is in the loop some time it puts out ID id = PRO 0 and through the next loop, ID = Pro 1 and if I have another record, then I would like to have an ID = Pro3

  print " & lt; input style = \" text align Do: center \ "type = \" text \ "name = \" product content \ "$ num \" value = \ "$ line [productivity] \" size = \ "5 \" id = \ "pro $ num \" & Gt; & Lt; / TD & gt; ";   

works with the above code

  var pro = document.getElementById ('pro0');   

What is the image after looping in java script which will take the last $ num from php and will use loop several times from the java script function.

I think something like this

  (i & lt; = $ num) {var {i} = document.getElementById ('supporter' [i]); if (pro [i] .value == "" } {InlineMsg ('supporter' [i], 'this can not be empty' [i], 10); the description is false;} and {i ++;}}   

all Fields are correct when This is true when it breaks, it is true. If I am getting this work, then I will be guessed how many variables are to be checked.

I have tried to do it, but I do not do it

  var i = 0; var pro [i] = document.getElementById ('pro' + i); (var i = 0; i   

This works but only for the first line. If the second line is AMTP and not the first line, then this warning does not occur

  var i = 0; (Var i = 0; i & lt; 3; i ++) for {var pro = document.getElementById ('support' + i); If (pro.value == "") warning ("You have entered:" + Pro [i] .value) returned false; }   

I have also changed the $ num variable to a fixed number for my test record to see if this was not passed to my variable and it is still the second

thanks for the solution

I = 0; Var Pro = []; For (var i = 0; i & lt; 2; i ++) {Pro [i] = document.getElementById ('support' + i); If (Pro [i] .value == "") {Warning ("You are logged in:" + Pro [i] .value);}

}

In javascript, you add a string using +

  supporter [i] = document.getElementById ('support' + i);   

For your loop, for

  (var i = 0; i   

Full code:

  var i = 0; Var Pro = []; (Var i = 0; i   

If you do not need a real array for anything, later on, you can do this:

  var i = 0 ; (Var i = 0; i & lt; & lt ;? php echo $ num? & Gt; ++) for (var i = 0;); Var pro = document.getElementById ('pro' + i); If (Prof.value == "") {Warning ("You have entered:" + pro.value) return false; }}    

Comments