Syntax Question:
I am new to Working on a Moodle form $mform stuff.
The BACKGROUND
Build test Form that has two fields 'email' and 'username'
'username' is Hidden !!
The GOAL
I would like the see the user type a value for 'email'
and
then trigger (perhaps - onblue or onchange or onSubmit; byID) or some method;
push the 'email' value into>> the 'hidden username' field?
The QUESTION??
What is the proper technique and/or syntax??
GIVEN:
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="25"');
$mform->addElement('hidden', 'username', null);
// can I call onblur or onchange of element email; put that value into hidden username field
// or some form of: var da_element = document.getElementById("email");
$mform->setDefault('username', da_element.value );
or????????
$mform->setDefault('username', document.getElementById("email").value );
or
$mform->setDefault('username', $this->myformname['email']);