i’m creating this application form that requires student’s personal details and newbie in javascript.
the intention is to auto-check the gender once user choose the relationship option accordingly;
if user choose Father, then auto-check at radio button is Male, if user choose Mother then Female radio button is checked.
I’ve created a table for that and here’s the table lokks like;
table name: RELATIONSHIP
RELCODE RELDESC RELGENDER
01 Father M
02 Mother F
03 Son M
04 Daughter F
And this is what i did so far, but unfortunately i still cannot get the right javascript function for this.
here’s the code:
[code=php]
<td>Relationship to Student </td>
<td><select name=T_RELATIONSHIP onchange=”javascript:submit_changes();”>
<?
if ($form_action == “refresh”)
{
$TT_RELATIONSHIP = $T_RELATIONSHIP;
}
$sequel = mysql_query(“SELECT RELCODE, RELDESC, RELGENDER FROM RELATIONSHIP”);
echo “<option value=”>–Choose Relationship–</option>n”;
if ($rs = mysql_fetch_array($sequel))
{
$T_RELCODE = $rs[0];
$T_RELDESC = $rs[1];
$T_RELGENDER = $rs[2];
echo “<option value=’$T_RELCODE’>$T_RELDESC</option>n”;
}
?>
</select></td>
<td>Gender </td>
<td><label><input type=”radio” name=”T_GENDER” value=”M” <? if ($T_RELCODE = “M”) { echo “checked”; }?>>Male</label>
<label><input type=”radio” name=”T_GENDER” value=”F” <? if ($T_RELCODE = “F”) { echo “checked”; } ?>>Female</label></td>
<script language=”javascript”>
function submit_changes()
{
document.FORM_RELATION.form_action.value = “refresh”;
document.FORM_RELATION.submit();
}
</script>