havent set up a test site to test this yet but I believe this may work...
in register.template.php
find
// Are there any custom fields?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
{
echo '
<tr valign="top">
<td width="40%"><b>', $field['name'], ': </b><div class="smalltext">', $field['desc'], '</div></td>
<td>', $field['input_html'], '</td>
</tr>';
}
}
and replace it with
// Are there any custom fields?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
{
if ($field['name'] == 'Role' && substr_count($field['input_html'],'eacher') > 0)
$field['input_html'] = rtrim($field['input_html'], '/>') . ' onclick="onselectteacher()"/>';
if ($field['name'] == 'Role' && substr_count($field['input_html'],'tudent') > 0)
$field['input_html'] = rtrim($field['input_html'], '/>') . ' onclick="onselectstudent()"/>';
echo '
<tr valign="top">
<td width="40%"><b>', $field['name'], ': </b><div class="smalltext">', $field['desc'], '</div></td>
<td>', $field['input_html'], '</td>
</tr>';
}
}
then find
echo '
// ]]></script>';
// Any errors?
and replace it with
echo '
document.forms["creator"].ifstudentchecked.style.visibility="hidden";
document.forms["creator"].ifteacherchecked.style.visibility="hidden";
function onselectteacher()
{
document.forms["creator"].role[1].checked=false;
document.forms["creator"].ifteacherchecked.style.visibility="visible";
document.forms["creator"].ifstudentchecked.style.visibility="hidden";
};
function onselectstudent()
{
document.forms["creator"].role[0].checked=false;
document.forms["creator"].ifstudentchecked.style.visibility="visible";
document.forms["creator"].ifteacherchecked.style.visibility="hidden";
};
// ]]></script>';
// Any errors?
where the string 'ifstudentchecked' should be replaced by the name of the field you wish to appear when student is checked.
and 'ifteacherchecked' similarly for teacher being checked'
for multiple fields repeat the three lines you need to edit the field for on the next line to where they are with the different field value.
This script should work if teacher and student are the value for checkboxes named role AND Teacher is above Student (I hard coded their positions).
I havent got a SMF 2 test site running atm so I haven't tested this code, so test its behaviour before relying on it (preferably not on your live site) and remember to back up before changing anything in case you need to undo the changes.
-edit- changed javascript where i had left testing code in -/edit-