Forum Moderators: open
I do not know much about Javascript, but I am hopeful that someone on here may have the answer for me!
I have a PHP document which has a recordset pulling data from a table. I have setup a form and I have placed a hidden form field within the form called "chargerIncluded". This hidden form form field is populated from the recordset as either Y or N.
I would like to enable or disable a form checkbox based on whether the charger was included (enabled if value of hidden form field is Y; disabled if value of hidden form field is N).
This is what I have got so far, but it does nothing!
function enableChkbox(check)
{if (document.form.chargerIncluded.value == 'Y')
{document.form["confirmChkbox"].disabled = false;
}
else
{document.form ["confirmChkbox"].disabled = true;
}
}
If you PHP looks something like this:
<input type="hidden" name="chargerIncluded" value="<?php
echo $chargerIncluded;
?>">
Then you could do:
<input type="hidden" name="chargerIncluded" value="<?php
echo $chargerIncluded;
?>">
<input type="checkbox" name="confirmChkbox" <?php
if ($chargerIncluded == 'N') {
echo 'disabled="disabled"';
}
?>>
I think that would work, and will work regardless of whether your end user has JavaScript enabled.