javascript - Generate Random URL, but URL length can't be changed fro some reason? -
as of i've been working on site bit of hobby during class. on site there basic text single button , text field. when press button generates random url , can add own extension it. @ moment it's send people random .onion domains. current problem cant length of url set random length. here code, if can recommend fix great. `
<body> <script> var 'x' = math.random() * 20 </script> <script language="javascript" type="text/javascript"> function randomstring() { var chars = "0123456789abcdefghiklmnopqrstuvwxyz"; var string_length = 'x'; var randomstring = ''; (var = 0; < string_length; i++) { var rnum = math.floor(math.random() * chars.length); randomstring += chars.substring(rnum, rnum + 1); } document.randform.randomfield.value = randomstring; } </script> <form name="randform"> <input type="button" value="generate new base url" onclick="randomstring();"> <input type="text" name="randomfield" value=""> </form> </body>
this works after fixed: 'x'
=> x
var x = math.random() * 20; function randomstring() { var chars = "0123456789abcdefghiklmnopqrstuvwxyz"; var string_length = x; var randomstring = ''; (var = 0; < string_length; i++) { var rnum = math.floor(math.random() * chars.length); randomstring += chars.substring(rnum, rnum + 1); } document.randform.randomfield.value = randomstring; }
<form name="randform"> <input type="button" value="generate new base url" onclick="randomstring();"> <input type="text" name="randomfield" value=""> </form>
Comments
Post a Comment