So I have a page with a checkbox which is a mysql boolean and a second that is a menu of mysql values. I need to greyout the menu unless the checkbox is checked. I can nearly do it with this code:
<script>
function setFHGoption(){
var el = document.getElementById("fhg");
if(el.checked)
document.getElementById("fhg_option").disabled = false;
else
document.getElementById("fhg_option").disabled = true;
}
</script>
<td class="main_check_box"><input <?php if (!(strcmp($row_demographics['gos_fhg'],1))) {echo "checked";} ?> name="fhg" type="checkbox" id="fhg" value="checkbox" onchange="setFHGoption();"/>
FHG </td>
</tr>
<select name="fhg_option" style="width:75px;" size="1" class="main_text_field" disabled="disabled" id="fhg_option">
<?php
do {
?>
<option value="<?php echo $row_gos_fhg_option['fhg_option_id']?>"<?php if (!(strcmp($row_gos_fhg_option['fhg_option_id'], $row_demographics['FK_gos_fhg_option']))) {echo "SELECTED";} ?>><?php echo $row_gos_fhg_option['fhg_option']?></option>
<?php
} while ($row_gos_fhg_option = mysql_fetch_assoc($gos_fhg_option));
$rows = mysql_num_rows($gos_fhg_option);
if($rows > 0) {
mysql_data_seek($gos_fhg_option, 0);
$row_gos_fhg_option = mysql_fetch_assoc($gos_fhg_option);
}
?>
</select>
Except on the page load if the boolean is 1 and the box is check the menu continues to be greyed out until the checkbox is toggled.
Any suggestions on how to overcome this?