<script type="text/javascript">
function serviceChange(list) {
if (value == "OTHER")
{
document.getElementById('others').style.display="inline";
}
else
{
document.getElementById('others').style.display="none";
}
}
</script>
<%= select_tag "options", options_for_select(MyModel::ALL_TYPES), :onchange => "serviceChange(this.options[this.selectedIndex].value);" %>
</p>
<p id="others">
<%= f.label :profile_url %><br />
<%= f.text_field :profile_url %>
</p>
I am having trouble with show and hide. Can anyone help me and explain why it is not working?
When I use function the function onchange like this, it also doesn’t work:
<%= f.select :xyz_type, MyModel::ALL_TYPES, :include_blank => true, :onchange => "checkType(this);" %>
in your first code block you have
but you never pass anything in called value or define what value is. That may be causing your issue. Try changing that to list if that’s what you’re passing in and trying to check against.
For your second question about the onchange not working, where is checkType defined? Post that function as well so there’s a little more information to work with.