title: My audio and search features don't function as intended
body: <p>I'm making a quick website and testing/trying out javascript, html, and css, but I've run into a couple of errors that I can't figure out how to deal with.</p>
  <ol>
  <li><p>In my dropdown menu with my search bar, the list of items that you can search show even when you're not selected onto the search.</p>
  </li>
  <li><p>I'm trying to get an audio to play when you increment the counter, but the audio randomly plays when you load the website.
  2a) The audio doesn't play when you click the increment button even though the <code>PlaySound()</code> function is referenced through <code>onclick</code> with the button.</p>
  </li>
  </ol>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function search()
  {
      var input, filter, ul, li, a, i, txtValue;
      input = document.getElementById("pgsearchbar").value;
      filter = input.toUpperCase();
      ul = document.getElementById("searchitems");
      li = ul.getElementsByTagName("li");
  
      for (i = 0; i &lt; li.length; i++)
      {
          finder = li[i].getElementsByTagName("a")[0];
          letter = finder.textContent || finder.innerText;
          if (letter.toUpperCase().indexOf(filter) &gt; -1)
          {
              li[i].style.display = "";
          }
          else
          {
              li[i].style.display = "none";
          }
      }
  }
  
  let counter = 0;
  
  function increment()
  {
      counter++;
      document.querySelector("#counter").innerHTML = counter;
  }
  
  function PlaySound(soundObj)
  {
      document.getElementById(soundObj).play();
  }
  
  function reset()
  {
      document.querySelector("#counter").innerHTML = 0;
      counter = 0;
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.pageselector
  {
      position:absolute;
      bottom:10%;
      left:45%;
  }
  
  .banner
  {
      background-image:url("sky.jpg");
      padding:60px;
      color:lightblue;
  }
  
  .banntxt
  {
      font-size:50px;
      text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
      font-family:"Faster One";
  }
  
  .navbar-brand
  {
      font-family:"Faster One";
      font-size:25px;
  }
  
  li
  {
      margin:3px 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;!DOCTYPE html&gt;
  
  &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"&gt;
          &lt;link href="styles.css" rel="stylesheet"&gt;
          &lt;link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Faster One"&gt;
          &lt;title&gt;My Webpage&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;
              &lt;div class="banner"&gt;
                  &lt;h1 class="banntxt"&gt;abcdefghijklmnop&lt;/h1&gt;
              &lt;/div&gt;
              &lt;nav class="navbar navbar-light" style="background-color: #e3f2fd;"&gt;
                  &lt;span class="navbar-brand mb-0 h1"&gt;ABC&lt;/span&gt;
                  &lt;h2 style="font-size:26px;"&gt;Contact us at: abcdefgh@gmail.com | ###-####-####&lt;/h2&gt;
                  &lt;button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"&gt;
                      &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
                  &lt;/button&gt;
                  &lt;div class="collapse navbar-collapse" id="navbarNav"&gt;
                      &lt;ul id="navbaritems" class="navbar-nav"&gt;
                          &lt;li class="nav-item active"&gt;
                              &lt;button type="button" class="btn btn-info disabled"&gt;Home&lt;/a&gt;
                          &lt;/li&gt;
                          &lt;li class="nav-item"&gt;
                              &lt;button onclick="window.location.href='#';" type="button" class="btn btn-info"&gt;About me&lt;/a&gt;
                          &lt;/li&gt;
                          &lt;li class="nav-item"&gt;
                              &lt;button onclick="window.location.href='#';" type="button" class="btn btn-info"&gt;Blah&lt;/a&gt;
                          &lt;/li&gt;
                          &lt;li&gt;
                              &lt;form class="form-inline"&gt;
                                  &lt;input id="pgsearchbar" class="form-control mr-sm-2" type="search" onkeyup="search()" placeholder="Search" aria-label="Search"&gt;
                                  &lt;ul id="searchitems"&gt;
                                      &lt;li&gt;
                                          &lt;a href="index.html"&gt;Homepage&lt;/a&gt;
                                      &lt;/li&gt;
                                      &lt;li&gt;
                                          &lt;a href="#"&gt;About Me&lt;/a&gt;
                                      &lt;/li&gt;
                                      &lt;li&gt;
                                          &lt;a href="page2.html"&gt;Page2&lt;/a&gt;
                                      &lt;/li&gt;
                                      &lt;li&gt;
                                          &lt;a href="page3.html"&gt;Page3&lt;/a&gt;
                                      &lt;/li&gt;
                                      &lt;li&gt;
                                          &lt;a href="page3.html"&gt;Page4&lt;/a&gt;
                                      &lt;/li&gt;
                                  &lt;/ul&gt;
                                  &lt;button class="btn btn-outline-info my-2 my-sm-0" type="submit"&gt;Search&lt;/button&gt;
                              &lt;/form&gt;
                          &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
              &lt;/nav&gt;
          &lt;/div&gt;
          &lt;div class="card text-center" style="width:11rem; left:60px; bottom:-30px;"&gt;
              &lt;div class="card-body"&gt;
                  &lt;h5 class="card-title"&gt;Counter&lt;/h5&gt;
                  &lt;p class="card-text" id="counter"&gt;0&lt;/p&gt;
                  &lt;button onclick="increment(); PlaySound(coin)" class="btn btn-primary"&gt;Increment&lt;/button&gt;
                  &lt;button onclick="reset()" class="btn btn-danger" style="margin:5px"&gt;Reset&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div style="position:absolute; bottom:10%; left:48.04%;"&gt;
              &lt;div class="btn-group" role="group" aria-label="Button group with nested dropdown"&gt;
                  &lt;div class="btn-group" role="group"&gt;
                      &lt;button id="dropdownMenuButton" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"&gt;
                          Page 1
                      &lt;/button&gt;
                      &lt;div class="dropdown-menu" aria-labelledby="btnGroupDrop1"&gt;
                          &lt;a class="dropdown-item disabled"&gt;1&lt;/a&gt;
                          &lt;a class="dropdown-item" href="page2.html"&gt;2&lt;/a&gt;
                          &lt;a class="dropdown-item" href="page3.html"&gt;3&lt;/a&gt;
                          &lt;a class="dropdown-item" href="page4.html"&gt;4&lt;/a&gt;
  
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;button onclick="window.location.href='page2.html';" type="btn" class="btn btn-secondary"&gt;-&gt;&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
          integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
          crossorigin="anonymous"&gt;&lt;/script&gt;
          &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"
          integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut"
          crossorigin="anonymous"&gt;&lt;/script&gt;
          &lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"
          integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k"
          crossorigin="anonymous"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="functions.js"&gt;&lt;/script&gt;
          &lt;embed src="coin.wav" autostart="false" width="0" height="0" id="coin" enablejavascript="true"&gt;
      &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>