title: Getting the current value of a text field without jQuery
body: <p>So I've been trying to get the current value of an input using an onclick event. I believe the issue likes with me binding a function to the button on page load so it only takes in the default value of the field. Is there a way around this using a non jQuery method.</p>
  
  <p>Code in the main html file.</p>
  
  <pre><code>&lt;div style="height:50px;"&gt;
    &lt;h3 style="width:50%;float:left;"&gt;Please enter an ordered set of numbers separated by commas&lt;/h3&gt;
    &lt;input style="float:right;" id="numbers" type="text" value="1,2,3,4,5,6,7,8,9,10"&gt;
  &lt;/div&gt;
  &lt;div style="height:50px;"&gt;
     &lt;input  style="float:right;" id="findMe" type="text" value="1"&gt;
     &lt;h3&gt;number to find&lt;/h3&gt;
  &lt;/div&gt;
  &lt;button id="runSearch"&gt;Index of&lt;/button&gt;the index is: &lt;span id="indexOf"&gt;&lt;/span&gt;
  
  &lt;script&gt;
  document.getElementById("runSearch").addEventListener('click',function() {findIndex()});
  &lt;/script&gt;
  </code></pre>
  
  <p>Separate JS file code.</p>
  
  <pre><code>function binarySearch(array, left, right, findMe, index){
  
  
      if (findMe &lt;0 || findMe === NaN || left &gt; right){
          console.log("not a number among other issues");
          return -1;
      }
  
      var middle = Math.round((right-left) /2) ;
      console.log(middle);
  
      if (array[middle] === findMe) {
          console.log("found it")
          return middle;
      }
  
      else if (findMe &lt; array[middle]) {
          console.log("it's smaller");
          return binarySearch(array,left,middle-1,findMe, middle);
      }
      else if (findMe &gt; array[middle]){
          console.log("is bigger");
          return binarySearch(array,middle+1,right,findMe, middle);
      }
      else {
          console.log("something else");
          return -1;
      }
  }
  
  
  //splits a CSV into an array of numbers
  function numbersIntoArray(numbers){
  
      return numbers.split(",");
  
  }
  
  function findIndex(){
      var numbers = document.getElementById("numbers").value;
      var findMe = document.getElementById("findMe").value;
      var array = numbersIntoArray(numbers);
      var index = binarySearch(array,0,array.length-1,2);
      console.log("the index is:" + index);
      document.getElementById("indexOf").innerHTML =index;
  }
  </code></pre>