title: Why my js function works inside of script tag and why not in an external javascript file django forms
body: <p>I have a form that displays plain text when component is checked, in django like below</p>
  <pre><code>class CompanySearchForm(forms.Form):
      check = forms.BooleanField()
  
      def __init__(self, *args, **kwargs):
          super(CompanySearchForm, self).__init__(*args, **kwargs)
          self.fields['check'].widget.attrs.update({&quot;onclick&quot;: 'show_p()', 'id': 'check'})
  </code></pre>
  <p>And i have also my js file with the following function</p>
  <pre><code>function show_p() {
      var checkBox = document.getElementById(&quot;check&quot;);
      var texto = document.getElementById(&quot;text&quot;);
      if (checkBox.checked == true){
          texto.style.display = &quot;block&quot;;
      } else {
          texto.style.display = &quot;none&quot;;
      }
  }
  </code></pre>
  <p>My template:</p>
  <pre><code>{% extends 'base.html' %}
  {% load static %}
  {% block extra_styles %}
      &lt;script href=&quot;{% static 'js/ajax_ubigeo.js' %}&quot;&gt;&lt;/script&gt;
  {% endblock %}
  {% block content %}
      &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
          {% csrf_token %}
          {{ form.check }}
      &lt;/form&gt;
      &lt;p id=&quot;text&quot; style=&quot;display: none&quot;&gt;hola&lt;/p&gt;
  {% endblock %}
  </code></pre>
  <p>My question is why <strong>show_p()</strong> works inside of <strong>script</strong> tag and inside the template. But why not in an external <strong>java script file</strong> ?</p>