title: How to pull a PHP echoed button's text into Javascript, whose value will be used in another PHP Sql query?
body: <p>I have a PHP sql query that returns a table. </p>
  
  <pre><code>while($row = $result-&gt;fetch_assoc()) {
                  echo "&lt;tr&gt;&lt;td id=\"cst\"&gt;&lt;button type=\"submit\" id=\"click\" onClick=sendData(this)&gt;".$row["Name"]&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;";
  </code></pre>
  
  <p>The table is output correctly. My next step is using vanilla Javascript to pull the HTML text value associated with $row["Name"] from the button in the output table (when the button is clicked). I call the function onClick=sendData(this)</p>
  
  <p>Now, in Javascript I'm attempting to access the text value like so:</p>
  
  <pre><code>function sendData(name) {
      var text = name.innerText;
  }
  </code></pre>
  
  <p>However, this isn't working. Can anyone explain why?</p>