Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7950401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:15:41+00:00 2026-06-04T02:15:41+00:00

I am trying to generate a random password ( this code’s running perfectly ),

  • 0

I am trying to generate a random password (this code’s running perfectly), which will be pasted to the value to the Password text box, but facing a problem while calling the javascript function.

Here is my JavaScript :

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<string_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        randomstring += chars.substring(rnum,rnum+1);
    }
    for (i=0,j = rows.length; i<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;
}

Here is my Table :

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

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:15:43+00:00Added an answer on June 4, 2026 at 2:15 am

    i would prefer to put this in a comment but i don’t have the reputation to yet.

    first off is there a specific reason you want the cells to be text input types? Since you are just disabling them on creation.
    also look into the rows[index].cells(); and table.rows(); methods in JS. these will give you an array of the cells and rows. from there you can iterate to where you want.
    visit to learn more http://www.javascriptkit.com/domref/tableproperties.shtml

    hope it helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code to generate random text : from collections import defaultdict,
I'm trying to generate several random doublesbetween 0 and 1. This is the code
I am trying to generate a random float with this code. float rangeDuration2 =
I am trying to generate a random password in php. However I am getting
This is a Javascript / jQuery question: I'm trying to generate six unique random
I have this hashed password with a random generated salt, and I'm trying to
I am trying to generate random text using letter frequencies that I have obtained.
I have a website. On this website, I am trying to generate random images.
I'm trying to generate a random string using this command: strings /dev/urandom | grep
I am trying to generate random numbers from a normal distribution. When the code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.