title: func is not defined at HTMLButtonElement.onclick
body: <p>I'm trying to create a simple webpage using Flask, I'm trying to capture the text written in a textfield in a javascript variable and then display it on console, when the user presses a button.</p>
  
  <p>Here is the code</p>
  
  <p><strong>HTML</strong></p>
  
  
  
  <pre><code>&lt;script type="text/javascript" language="javascript" src="{{url_for('static',filename='js/main.js')}}"&gt;&lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;div class="row"&gt;
        &lt;div class="col-md-3"&gt;&lt;/div&gt;
        &lt;div class="col-md-6"&gt;
          &lt;input type="text" id="txtWord" name="search" placeholder="Search..." &gt;
        &lt;/div&gt;
        &lt;div class="col-md-3"&gt;&lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
        &lt;div class="col-md-3"&gt;&lt;/div&gt;
        &lt;div class="col-md-6"&gt;
          &lt;input type="text" name="search" placeholder="# Result..." id="inputNumResults"&gt;
        &lt;/div&gt;
        &lt;div class="col-md-3"&gt;&lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
        &lt;div class="col-md-4"&gt;&lt;/div&gt;
        &lt;div class="col-md-4 text-center"&gt;
          &lt;br&gt;
          &lt;button class="btn btn-success" type="button" id="buttonSearch" onclick="getText()"&gt;Search for words&lt;/button&gt;
        &lt;/div&gt;
        &lt;div class="col-md-4"&gt;&lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>function getText() {
      var txt = document.getElementById('txtWord').innerHTML;
      console.log(txt);
  }
  </code></pre>