I am working on a dynamic form input display where if the users clicks something to show "advanced options" in the form, the input vectors will be displayed, but otherwise (the default) they will not be shown. I have the following pieces in my form partial:

UPDATED 1x:

```
<div class="form-inputs">
    <%= f.input :message, label: 'Write message'%>
</div>

<div class="form-inputs">
  <%= f.check_box :advanced, {}, :id => "advancedbox" %>
</div>

<div class="form-inputs" id="advancedopts" style="display:none;">          
  <%= f.input :startdatetime, label: 'Specify', :as => :datetime_picker %>
  <%= f.input :expirationdatetime, label: 'Specify', :as => :datetime_picker %>
</div>

```

And the JS in the head of the form partial:

UPDATED 1x:

```
<head><script type="text/javascript">
var checkbox = document.getElementById('advancedbox');
checkbox.onchange = function() {
if (checkbox.checked) {
      document.getElementById("advancedopts").style.display = "block;";
  } else {
      document.getElementById("advancedopts").style.display = "none;";
  }
}
</script></head>

```

I took the inspiration for this from the following post: [show rest of a form if a checkbox is ckecked in ruby on rails](https://stackoverflow.com/questions/10322444/show-rest-of-a-form-if-a-checkbox-is-ckecked-in-ruby-on-rails)

But I cannot get it to work: the checkbox shows, but clicking it on or off does not show my advanced form inputs. Can anyone help me debug?

Thanks!!