User_Registration Access Group field javascript question
When you select Administrator from the Access Group field when adding a new user. The form fields change using the users_regstration.js script. I need a third form option and would like to try to reuse this function if possible rather than use links to separate versions of the form.
I figured I could simply add a new form giving it a unique ID and adding to the users_registration.js and then edit the form fields as nessisary and of course add the insert code etc.
This is the new version of the users_regitration.js but I must be doing something wrong. My knowledge her is minimal.
function toggleUserFields(select) {
if(select.options[select.selectedIndex].value == 2) {
document.getElementById('WAATKRegistrationForm').style.display = 'none';
document.getElementById('AdminRegistrationForm').style.display = 'block';
document.getElementById('CompanyRegistrationForm').style.display = 'none';
document.getElementById('UserAccessAdmin').selectedIndex = document.getElementById('UserAccess').selectedIndex;
}
else if(select.options[select.selectedIndex].value == 3) {
document.getElementById('WAATKRegistrationForm').style.display = 'none';
document.getElementById('AdminRegistrationForm').style.display = 'none';
document.getElementById('CompanyRegistrationForm').style.display = 'block';
document.getElementById('UserAccessAdmin').selectedIndex = document.getElementById('UserAccess').selectedIndex;
}
else {
document.getElementById('WAATKRegistrationForm').style.display = 'block';
document.getElementById('AdminRegistrationForm').style.display = 'none';
document.getElementById('CompanyRegistrationForm').style.display = 'none';
}
}
window.onload = function() {
toggleUserFields(document.getElementById('UserAccess'));
}