title: using addEventListener function inside view Google Linechart function
body: <p>I have an html drop down that I want to connect with a google linechart in order to filter data. I have an event listener inside a <code>setChartView</code> function. I want to set specific columns based on what the user selects. </p>
  
  <p>In this case:</p>
  
  <pre><code>view.columns.push(columnsTable.getValue(4, 1)); 
  view.columns.push(columnsTable.getValue(5, 1));
  </code></pre>
  
  <blockquote>
    <p>The problem is, I cannot put these view requests inside my if statements because they are not defined within the scope of the event listener. I can take my if statement out of the event listener and say <code>if (a.value == 'selectedValue')</code> but then the event listener only takes the default selected value (in this case, 'maint') and does not recognize changed value <code>a</code>.</p>
  </blockquote>
  
  <p>How do I put my view requests </p>
  
  <pre><code>view.columns.push(columnsTable.getValue(4, 1)); 
  view.columns.push(columnsTable.getValue(5, 1));
  </code></pre>
  
  <p>inside my listener? And have these <code>setChartView</code> values recognized within the listener?</p>
  
  <p>I've tried adding <code>setChartView</code> to the Listener parameters, calling <code>setChartView</code> after the function declaration and have been referencing this <a href="https://www.w3schools.com/jsref/met_document_addeventlistener.asp" rel="nofollow noreferrer">https://www.w3schools.com/jsref/met_document_addeventlistener.asp</a> </p>
  
  <p>I feel like I'm missing something quite simple?</p>
  
  <pre><code>    function setChartView(linechart, columnsTable, columnFilter) {
          var state = columnFilter.getState();
          var row;
          var view = {
              columns: [0]
          };
  
           var a = document.getElementById('select');
           a.addEventListener('change', function() {
  
                if (this.value = 'maint'){
                   console.log('maint');
  
                } else if (this.value = 'ru'){
                   console.log('ru');
  
                } else if (this.value = 'sf'){
                   console.log('sf');
                }
  
                }, false);
  
  
  
          view.columns.push(columnsTable.getValue(4, 1)); 
          view.columns.push(columnsTable.getValue(5, 1));
  
          // sort the indices into their original order
          view.columns.sort(function (a, b) {
              return (a - b);
          });
  
          linechart.setView(view);
          linechart.draw();
      }// end setChartView
  </code></pre>