title: can't fetch value from frontend… “document.querySelector('#text').value;” not working
body: <p>html code :</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
      document.addEventListener('DOMContentLoaded', () =&gt; {
          var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port);
          socket.on('connect', () =&gt; {
                  const selection = document.querySelector('#text').value;
                  socket.emit('submit value', {'selection':selection});
              });
          socket.on('submit text', data =&gt; {
              const li = document.createElement('li');
              li.innerHTML = `msg: ${data.selection}`;
              document.querySelector('#list').append(li);
          });
      });
  &lt;/script&gt;
  &lt;title&gt;chat room&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1 style=&quot;font-family:verdana; font-style:italic;&quot;&gt;Chat room!!!&lt;/h1&gt;
      &lt;ul id=&quot;list&quot;&gt;
      &lt;/ul&gt;
      &lt;hr&gt;
      &lt;form id=&quot;chat&quot;&gt;
          &lt;input id=&quot;text&quot; autocomplete=&quot;off&quot; autofocus placeholder=&quot;enter text&quot;&gt;
          &lt;input type=&quot;submit&quot;&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  <p>python code :</p>
  <pre><code>import os
  
  from flask import Flask, render_template
  from flask_socketio import SocketIO, emit
  
  app = Flask(__name__)
  app.config[&quot;SECRET_KEY&quot;] = os.getenv(&quot;SECRET_KEY&quot;)
  socketio = SocketIO(app)
  
  
  @app.route(&quot;/&quot;)
  def index():
      return render_template(&quot;index.html&quot;)
  
  @socketio.on(&quot;submit value&quot;)
  def chatting(data):
      selection=data[&quot;selection&quot;]
      print(selection)
      emit(&quot;submit text&quot;, {&quot;selection&quot;:selection}, broadcast=True)
  </code></pre>
  <p>Hello everyone, I'm trying to make a 'chat room' for my course project and, above is my code. So when I submit my form nothing happens, I don't get any output. It Seems my entered text didn't go to the server. Please help me solve this issue. Thank you.</p>