looping in javascript
<p>as before the below code is in a while loop . it out puts values id=pro0 then next loop through i get id=pro1 and if i have another record i get id=pro3   </p>

<pre><code>print "&lt;td&gt;&lt;input style=\"text-align:center\" type=\"text\" name=\"productitemsupdate_$num\" value=\"$row[productitems]\" size=\"5\" id=\"pro$num\"&gt;&lt;/td&gt;";
</code></pre>

<p>the above code works with </p>

<pre><code>var pro = document.getElementById('pro0');
</code></pre>

<p>what im after is a loop in java script which will take the last $num from the php from and use that for the amount of times to loop the javascript function.</p>

<p>something like this i think</p>

<pre><code>var i=0;
while (i&lt;=$num) {
    var pro[i] = document.getElementById('pro'[i]);
    if (pro[i].value == "") {
        inlineMsg('pro'[i],'This cannot Be blank'[i],10);
        return false;
    } else {
        i++;
    }
}
</code></pre>

<p>breaks when it is false when all fields are right it is true.
if i get this working it will save me guessing how many variable to check.</p>

<p>i have tried this but i cant this working either</p>

<pre><code>var i=0;
var pro[i] = document.getElementById('pro' + i);
for(var i = 0; i &lt; &lt;?php $num ?&gt;; i++) {
    if(pro[i].value == "")
        alert("You entered: " + pro[i].value)
    return false;
}
</code></pre>

<p>this works but only for the first line. if the 2nd line is emtpy and the first line is not it does not produce the alert</p>

<pre><code>var i=0;
for(var i = 0; i &lt; 3; i++) {
var pro = document.getElementById('pro' + i);
if(pro.value == "")
alert("You entered: " + pro[i].value)


return false;
}
</code></pre>

<p>i also changed the $num variable to a static number for my test record to see if it was my variable not being passed and it still did't work for the 2nd record any ideas</p>

<p>thanks</p>

<p>steve</p>

<p>working solution thanks for your help</p>

<pre><code>var i=0;
var pro = [];

for(var i = 0; i &lt; 2; i++) {
pro[i] = document.getElementById('pro' + i);
if(pro[i].value == ""){
    alert("You entered: " + pro[i].value)
return false;}
</code></pre>

<p>}</p>
