A Customer had a need as part of a Case Workflow to generate a Self Service username and password for their contacts. They were using an ASP page to do this and asked whether I had any code to generate a password for Self Service.
This is a simple little script and you may find this useful for your own projects.
function makePassword()
{
var strPassword = '';
var strChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for (i=1;i<8;i++) {
var x = Math.floor(Math.random() * strChars.length + 1);
strPassword += strChars.charAt(x)
}
return strPassword;
}
The usage is very simple
var strMyPassword = makePassword();