title: How can I get the value of an input and split the words by comma?
body: <p>I'm working on a search feature for my ecom project. What I'm trying to do is take the data from an input in <code>index.html</code>, and then redirect to <code>search.html</code> while still being able to hold the data, but the page just reloads and nothing is showing up in the console field.</p>
  <p>I'm using vanilla JavaScript and running into some issues.</p>
  <p>This is my HTML</p>
  <pre><code>  &lt;form action=&quot;search.html&quot;&gt;
      &lt;input
        type=&quot;text&quot;
        placeholder=&quot;Search for products&quot;
        id=&quot;search-query&quot;
      /&gt;
    &lt;/form&gt;
  </code></pre>
  <p>and this is my JavaScript</p>
  <pre><code>document.getElementById(&quot;search-query&quot;).addEventListener(&quot;focus&quot;, function () {
    const search = document.getElementById(&quot;search-query&quot;).value;
    const searchResults = search.split(&quot; &quot;);
    console.log(searchResults);
  });
  </code></pre>
  <p>I'm using the split method because I want each word separated by a comma. I plan on implementing a feature that displays images based on each word, but for now I just want the results to log to the console so I know I'm not getting an undefined, but nothing I try seems to be working.</p>
  <p>I was able to get the code working just fine when I was only logging the value of the input, but I need a way to redirect to <code>search.html</code>, which is why I wrapped it in the <code>form</code>.</p>