I am learning php and html.
I am trying to make a function run when a submit button is pressed. Then I want it to edit a text field on my form with the variable from that function. Without going to a new page…like a self refresh.
How do I do this? Thanks.
I think I have seen how to do this with JavaScript getelementbyID. But I need to do it via php.
Perhaps an easy way to explain it is this: When button is pressed it generates a password in a text field automatically.
The function I am using:
<?
function genkey($length){
$key = '';
list($usec, $sec) = explode(' ', microtime());
mt_srand((float) $sec + ((float) $usec * 100000));
$possibleinputs = array_merge(range('z','a'),range(0,9),range('A','Z'));
for($i=0; $i<$length; $i++) {
$key .= $possibleinputs{mt_rand(0,61)}; }
return $key;
}
?>
like this: