title: javascript searching a json object
body: <p>I'm trying to search a value in json</p>
  
  <pre><code>&lt;input type="text" id="test" size="21" maxlength="120"&gt;
  &lt;button onclick="Zoek()" class="btn btn-info btn-block"&gt;
          tijdelijke zoek knop
  &lt;/button&gt;
  </code></pre>
  
  <p>I'm using this to input a value and the button to call the search function</p>
  
  <pre><code>function Zoek() {
      var qeustion = document.getElementById("test").value;
      document.getElementById("accordion").innerHTML == "";
      var text = '{ "FAQ" : [' +
          '{ "vraag":"John" , "antwoord":"Doe" },' +
          '{ "vraag":"Anna" , "antwoord":"Smith" },' +
          '{ "vraag":"Peter" , "antwoord":"Jones" } ]}';
  
      obj = JSON.parse(text);
  
      for (i = 0; i &lt; text.length; i++) {
          if (obj.FAQ[i].vraag == qeustion) //(obj.FAQ[i].getString("vraag").contains(question))
          {
              document.getElementById("accordion").innerHTML += "&lt;div class='panel panel-default'&gt;&lt;div class='panel-heading' role='tab' id='heading" + i + "'&gt;&lt;h4 class='panel-title'&gt;&lt;a data-toggle='collapse' data-parent='#accordion' href='#" + i + "' aria-expanded='false' aria-controls='" + i + "''&gt;" + obj.FAQ[i].vraag + " &lt;/a&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div id='" + i + "' class='panel-collapse collapse in' role='tabpanel' aria-labelledby='heading" + i + "'&gt;&lt;div class='panel-body'&gt; " + obj.FAQ[i].antwoord + "&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; WOWOWOWOWOWOWOWOWWOWOWOOW";
          } else {
              document.getElementById("accordion").innerHTML = "No results found"
          }
      }
  }
  </code></pre>
  
  <p>and this is my search function</p>
  
  <p>so lets say i enter John it goes straigt to the else and doesnt do the if statement even though i am pretty sure it kind of is right</p>
  
  <p>could anyone give me some pointers on searching in a json object? is there a other way to do this?</p>