I wrote a javascript program to generate random passwords. How can I output the result into a textfield (input tag)?
var randomString = function(length) {
var text = "";
var possible = "!@[|^]µ§$%&?*€#ABCDEFGHIJKLMNOPQRSTVWXYZabcdefghijklmnopqrstvwxyz1234567890";
for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
var rs = randomString(16);
console.log(rs);
<section id="passgen">
<button type="button" id="pass-button" onclick="**???**">Generate Password</button>
<br><br>
<input type="text" name="output">
</section>