Fill Field, After Clicking the Button Element

tiagovareta

Member
Hi,

I added a button element on my form. This button executes a javascript code to create a random password:

function randomPassword(length) {
var chars = "abcdefghijklmnopqrstuvwxyz#$%&BCDEFGHIJKLMNOP1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
pass += chars.charAt(i);
}
return pass;
}

The thing is that I wanted to click the button, the generated password was assigned to the value of the password field (password_ctg).

How can I assign the generated value to the field using javascript?
 
Hi,

I've been able to solve this situation! To assign a value to a field, using javascript I used:

$('tablename___fieldname').value = randomPassword(8);
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top