Add/Remove form field depending on radio select value
I'm currently building a medical form, and I want to make it a little more
dynamic. So, one of the first fields is a radio that indicates whether the
patient is male or female, and I'd like that when you choose one of those,
the fields that are related to the other genre dissapear.
I tried something like this:
<script type="text/javascript">
$('#Sex').change(function(){
if($(this).val() == "Male"){
$('#FemaleRelatedField').remove();
}
});
</script>
Where #Sex is a radio type field (Male/Female) and #FemaleRelatedField is
any given field that we won't need to answer when dealing with a male
patient.
But it doesn't seem to work at all.
Thanks in advance for all of your answers.
EDIT: Fixed the little typo, but it didn't solve the issue.
No comments:
Post a Comment