...

View Full Version : Make script work on load



itxtme
12-31-2011, 12:18 AM
I am trying to make the following fill the value box when the page loads as opposed to pressing the button. I cant seem to do it. Any ideas??


<script>
var keylist="abcdefghijklmnopqrstuvwxyz123456789"
var temp=''

function generatepass(plength){
temp=''
for (i=0;i<plength;i++)
temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
return temp
}

function populateform(enterlength){
document.pgenerate.output.value=generatepass(enterlength)
}
</script>

<form name="pgenerate">
<input type="text" size=18 name="output">
<input type="button" value="Generate Password" onClick="populateform(this.form.thelength.value)"><br />
<b>Password Length:</b> <input type="text" name="thelength" size=3 value="7">
</form>

xelawho
12-31-2011, 12:22 AM
like this?



<html>
<head>
</head>
<body onload="populateform(document.pgenerate.thelength.value)">
<script>
var keylist="abcdefghijklmnopqrstuvwxyz123456789"
var temp=''

function generatepass(plength){
temp=''
for (i=0;i<plength;i++)
temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
return temp
}

function populateform(enterlength){
document.pgenerate.output.value=generatepass(enterlength)
}
</script>

<form name="pgenerate">
<input type="text" size=18 name="output">
<b>Password Length:</b> <input type="text" name="thelength" size=3 value="7">
</form>
</body>
</html>

itxtme
12-31-2011, 12:23 AM
Legend, thanks heaps! Now to learn the code~!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum