I need some help with the following; I want to display a newly generated password(function in php)when the button "gww" is clicked inside another input field. Could someone shed some light?
<td><input type="button" value="Generate" name="gww"></td>
<td><input type="text" id="ww"></td>
<script type="text/javascript">
function password()
{
var elem = document.getElementById("ww");
elem.value = "<? echo random_Password(); ?>";
}
</script>
function random_Password($length = 8)
{
//empty password string
$password = "";
//Possible characters
$karakters = "123456789abcdefghijklmnpqrstuvwxyz";
$maxlength = strlen($karakters);
if($length > $maxlength)
{
$length = $maxlength;
}
$i = 0;
while($i < $length)
{
$char = substr($karakters, mt_rand(0, $maxlength-1), 1);
if(!strstr($password, $char))
{
$password .= $char;
$i++;
}
}
return $password;
}