Assigning the random password value to a particular column (cells)
<p>I am trying to generate a random password (<em>this code's running perfectly</em>), which will be pasted to the value to the Password text box, but facing a problem while calling the javascript function.</p>

<p>Here is my JavaScript :</p>

<pre><code>function password() {
    var chars =   "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var string_length = 8;
    var randomstring = '';
    var table = document.getElementById('table'),
    rows = table.getElementsByTagName('tr'),
    i,j, cells, password;
    for (var i=0; i&lt;string_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        randomstring += chars.substring(rnum,rnum+1);
    }
    for (i=0,j = rows.length; i&lt;j;++i)
    {
    cells = rows[i].getElementsById('td');
    if(!cells.length)
    {continue;
    }
    password = cells[j].innerText;
    alert("hi "+password);
    }
    alert("Password is : "+randomstring);
    document.f2.password.value = randomstring;
}
</code></pre>

<p>Here is my Table :</p>

<pre><code>&lt;table name="table" id="table" cellpadding="4" cellspacing="2" border="1" bgcolor="" &gt;
&lt;tr name="tr" id="tr"&gt;
&lt;th&gt;&lt;input type="checkbox" name="allCheck" onclick="selectallMe()"&gt;&lt;/th&gt;
&lt;th&gt;Emp ID&lt;/th&gt;
&lt;th&gt;Device&lt;/th&gt;
&lt;th&gt;Feature Status&lt;/th&gt;
&lt;th&gt;Policy&lt;/th&gt;
&lt;th&gt;Password Management&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;%  while(rs.next()){ %&gt;
&lt;td&gt;&lt;input type="checkbox" name="chkName" onclick="selectall()"&gt;&lt;/td&gt; 
&lt;td&gt;&lt;input type="text"  name="empId" value="&lt;%= rs.getString(1)%&gt; "   disabled="disabled"  maxlength="10"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" name="device" value="&lt;%= rs.getString(2)%&gt;"   disabled="disabled" maxlength="10"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text"  name="features" value="&lt;%= rs.getString(3)%&gt;"  disabled="disabled" maxlength="60"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text"  name="policyName" value="&lt;%= rs.getString(4)%&gt;"  disabled="disabled" maxlength="10"&gt;&lt;/td&gt;
&lt;td id="td" name="td"&gt;&lt;input type="text" name="password" id="password" value=""  &gt;&lt;input type="button" name="Password" value="Password" onclick="password()"&gt;&lt;input type="reset"  name="Reset" value="Rseset"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;% } 
%&gt;
&lt;/table&gt;
</code></pre>

<p>In my JS what is going wrong?? As I want to iterate through Password column, <code>Password()</code> will assign the value to the Password cells.</p>
