Using the onclick method to grab $this row and populate a web form
<p>I am trying to select data from a table row and use that very data in a web form. I've been able to pass the record id as a data-attribute of the row. I am stuck on the part where I have to use the $.on() function and also what do I put in the PHP Webform that will be associated with this Javascript code?</p>

<p>Thanks</p>

<h2>Here is the Javascript</h2>

<pre><code>$(document).on('click', 'tr', function() {

        //Get the ID from the row clicked
        var id = $(this).data('recordId'); 

        //short-hand
        $('#section2').load('data_entry_form.php?id='+id);

});
</code></pre>

<h2>Here is the PHP for the Web Form (see the first few lines where I try to "catch" the record id that was selected by the user.</h2>

<pre><code>&lt;html&gt;
&lt;form&gt;
&lt;?php
   $_GET['id'];

   echo $id; //should echo the id being sent across.
?&gt;
&lt;input type="date"&gt;&lt;/input&gt;&lt;br&gt;
&lt;input list="auditors" placeholder="Auditor" /&gt;
&lt;datalist id="auditors"&gt;
    &lt;option value="Foo" /&gt;
&lt;/datalist&gt;&lt;br&gt;
&lt;input list="city" placeholder="City" /&gt;
&lt;datalist id="city"&gt;    
    &lt;option value="Bar" /&gt;
&lt;/datalist&gt;&lt;br&gt;
&lt;input type="submit" name="submitbutton" id="submitbutton" value="Submit" /&gt;
&lt;/form&gt;
&lt;/html&gt;
</code></pre>

<h2>Here is the PHP that generated the original table that I selected the rows from. Here I have passed a data-attribute which is the "fee_source_id" (identical to the first column in the table).</h2>

<pre><code>&lt;?php
require_once 'config.php';

$dbh = new PDO($dsn, $dbuser, $dbpass);

$dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

$result = $dbh-&gt;query("
    SELECT a_aif.aif_id,
      a_aif.fee_source_id,
      a_aif.company_name_per_sedar,
      a_aif.document_filing_date,
      IF (a_aif_remaining.aif_id IS NULL, 0, 1) `match`
    FROM  a_aif
      LEFT JOIN a_aif_remaining
        ON a_aif_remaining.aif_id = a_aif.aif_id
    WHERE aif_id = {$id}
    ORDER BY aif_id DESC");

$result-&gt;setFetchMode(PDO::FETCH_ASSOC);

if ( !empty($result) ) : endif;

?&gt;

&lt;table = "all_aifs"&gt;
&lt;tr&gt;
    &lt;th&gt;&lt;b&gt;Document ID&lt;/b&gt;&lt;/th&gt;
    &lt;th&gt;&lt;b&gt;Pubco Name&lt;/b&gt;&lt;/th&gt;
    &lt;th&gt;&lt;b&gt;Filing Date&lt;/b&gt;&lt;/th&gt;
    &lt;th&gt;&lt;b&gt;PDF&lt;/b&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;?php foreach($result as $index =&gt; $row) : ?&gt;
&lt;tr data-recordId="&lt;?=$row[fee_source_id];?&gt;"
    class="&lt;?=$row["match"] ? "match" : "";?&gt;"&gt;
    &lt;td&gt;&lt;?php echo $row[fee_source_id]; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row[company_name_per_sedar]; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row[document_filing_date]; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;? endforeach;?&gt;
&lt;/table&gt;
</code></pre>

<p><img src="http://i.stack.imgur.com/qRiK0.png" alt="enter image description here"></p>
