{% for field in form %}
  {% if field.field.extra.show_if_selected %}
    {% with field.field.extra.show_if_selected.0 as select %}
      <script>
        var show_function = function (){
          var show = false;
          {% for value in field.field.extra.show_if_selected.1 %}
            if($('#{{select.auto_id}}').val() == '{{value}}')
              show = true;
          {% endfor %}
          if(show)
            $('#{{field.auto_id}}').show()
          else
            $('#{{field.auto_id}}').hide()
        };
        $(document).ready(show_function);
        $('#{{select.auto_id}}').change(show_function);
      </script>
    {% endwith %}
  {% endif %}
  {% if field.field.extra.show_if_checked %}
    {% with field.field.extra.show_if_checked as checkbox %}
      <script>
        var show_function = function() {
          if($('#{{checkbox.auto_id}}')[0].checked)
            $('#{{field.auto_id}}').show()
          else
            $('#{{field.auto_id}}').hide()
        };
        $(document).ready(show_function);
        $('#{{checkbox.auto_id}}').change(show_function);
      </script>
    {% endwith %}
  {% endif %}
{% endfor %}
