I'm assuming #subject_enrolled
is a checkbox. You just need to listen for the change events on that checkbox and then update the display of your #subject_reason_not_enrolled
. This is covered quite a bit in other posts. Here's one: How to listen to when a checkbox is checked in Jquery
Ruby on Rails: Jquery/ajax dynamic form fields
-
14-10-2022 - |
سؤال
I'm in the process of implementing dynamic form fields. So far, I have some jQuery that does the trick, however I have to manually refresh the page to see the change.
How can I make this dynamic? I'm under the impression I'll need to include ajax somewhere, but I'm having issues finding good resources.
Here is the code I'm using;
jQuery ->
$(
if ($('#subject_enrolled').val() == '0')
$('#subject_reason_not_enrolled').show()
else
$('#subject_reason_not_enrolled').hide();
);
Any help/resources would be greatly appreciated.
المحلول
لا تنتمي إلى StackOverflow