title: How to get ROW id from dynamic ajax generated table (PHP, JQuery, MySQL)
body: <p>Okay so I have been working on this small project, I have done this before; using jquery when clicking on table row gives an ID/value, but not with php or ajax. So I'm kinda lost, before the ajax query the table has a preset row with information in it. When I click on it everything works fine, but after selecting a source from the drop down menu (the source is a name to search for all rows containing a certain name) and it load all related rows into the table. Clicking on a row jquery does nothing on the generated data, but when clicking on the thead it launches the test alert I have set up. I am using HotKeys to open hidden popup windows for the user to interact with the form/page.<br>
  <br>
  <code>jquery-1.7.1.js.js</code><br>
  <code>jqueryhotkeys.js</code><br><br>
  <strong>External JS File</strong>:<code>eval.js</code><br></p>
  
  <pre><code>var s,
      Joe = {
          settings: {                 
          winWidth:       $(window).width(),
          winHeight:      $(window).height(),
          entriesPopW:    $('#overlay_entries').width(),
          entriesPopH:    $('#overlay_entries').height()
      },
      init: function() {
          s = this.settings;
          this.bindUIActions();
      },
      bindUIActions: function() {                 
          $(document).bind('keydown.f7',function (evt){
              //View Previous Entries
              $("#overlay_entries").fadeIn(1000);Joe.entries();Joe.loadEntries();
              $("#assList").change(function(e){
                  assSelect = $("#assList").val();
                  Joe.entryTable(assSelect);
              });
              $("#table-2 tr").click(function() {
                  alert("You clicked ROW:\n\nID:  " + $(this).attr('id'));
              });
              $(".f7button").click(function(x){$("#overlay_entries").fadeOut(500);return false;});
              return false; 
          });             
      },
      //shows or hides hidden window
      entries: function(){if(!$("#overlay_entries").is(':visible')){return;} $("#overlay_entries").css({  left: (s.entriesPopW/2)+50 ,top: (s.entriesPopH/2)+50,position:'fixed'   }); },
      //populates table after drop down menu selection
      entryTable: function(a){
          var jac = a;
          $.ajax({
              type: "GET",
              url: "joe_functions.php?select="+jac,
              error: function() {alert('error');},
              success: function (data) {
                  $("#table-2 tbody").ajaxComplete(function () {
                      $(this).html(data);                    
                  });
              }
          }); 
      },
      //this loads the dropdown menu with names
      loadEntries: function(){
          $.ajax({
              type: "GET",
              url: "joe_functions.php?content=dropdown",
              error: function() {alert('error');},
              success: function (data) {$("#assList").ajaxComplete(function () {$(this).html(data);});}
          });
      }
  };
  </code></pre>
  
  <p><strong>HTML File</strong><br>
  </p>
  
  <pre><code>&lt;head&gt;
      &lt;title&gt;The Eval Form&lt;/title&gt;
      &lt;script src="jquery-1.7.1.js"&gt;&lt;/script&gt;
      &lt;script src="jquery.hotkeys.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="eval.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          (function() {Joe.init();})();
      &lt;/script&gt;
  &lt;style&gt;
  &lt;/style&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="overlay_entries" style="display:none"&gt;
      &lt;h2&gt; Previous Entries:&lt;/h2&gt;
      &lt;center&gt;
          &lt;select name="" id="assList"&gt;&lt;/select&gt;&lt;br/&gt;&lt;br/&gt;    
          &lt;table id="table-2"&gt;
              &lt;thead&gt;
                  &lt;th class="entryColOne"&gt;Associate&lt;/th&gt;
                  &lt;th class="entryColTwo"&gt;Eval Date&lt;/th&gt;
                  &lt;th class="entryColThree"&gt;Score&lt;/th&gt;
                  &lt;th class="entryColFour"&gt;Overall&lt;/th&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;td&gt;John&lt;/td&gt;
                      &lt;td&gt;Smith&lt;/td&gt;
                      &lt;td&gt;johnsmith@example.com&lt;/td&gt;
                      &lt;td&gt;http://www.example.com&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
          &lt;br/&gt;
          &lt;input type="submit" class="f7button" value=""/&gt;
      &lt;/center&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><br>
  <strong>PHP File:</strong> <code>joe_functions.php</code></p>
  
  <pre><code>&lt;?php
  require 'db_connect.php';
  
  if(isset($_GET['select']) &amp;&amp; !empty($_GET['select'])){
      $passed = $_GET['select'];
      //$test = '&lt;tr&gt;&lt;td colspan=4"&gt;'.$passed.'&lt;/td&gt;&lt;/tr&gt;';
      $sqlb   = 'SELECT * FROM joe_eval WHERE wmid ='.$passed.' ORDER BY id';
      $queryb     = mysql_query($sqlb);
      $numb   = mysql_num_rows($queryb);
  
      $tableData = '';
      $ib = 0;
      if(!$queryb){
          $query_error = '&lt;tr&gt;&lt;td colspan="4"&gt;MySQL Error: '.mysql_error().'&lt;/td&gt;&lt;/tr&gt;';
          $tableData .= $query_error;
      }else{
          while($ib &lt;$numb){
              $wmid   = mysql_result($queryb,$ib,'wmid');
              $person     = mysql_result($queryb,$ib,'employee'); 
              $id = mysql_result($queryb,$ib,'id');
              $date       = mysql_result($queryb,$ib,'date');
              $score      = (mysql_result($queryb,$ib,'dm1')+mysql_result($queryb,$ib,'dm2')+mysql_result($queryb,$ib,'dm3')+mysql_result($queryb,$ib,'dm4')+mysql_result($queryb,$ib,'dm5')+mysql_result($queryb,$ib,'dm6')+mysql_result($queryb,$ib,'dm7'))/7;
              $numFormat = number_format($score, 2, '.', '');
              $overall    =   '';
  
              if ($numFormat &gt;= 1 &amp;&amp; $numFormat &lt; 1.6) {$overall = 'Below Needs';
              }else if ($numFormat &gt;= 1.6 &amp;&amp; $numFormat &lt; 2.7) {$overall = 'Improvment Needed';
              }else if ($numFormat &gt;= 2.7 &amp;&amp; $numFormat &lt; 3.6) {$overall = 'Good Performer';
              }else if ($numFormat &gt;= 3.6 &amp;&amp; $numFormat &lt; 4.6) {$overall = 'Exceeds Expectations';
              }else if ($numFormat &gt;= 4.6 &amp;&amp; $numFormat &lt;= 5) {$overall = 'Top Dog';}
  
                  // HERE IS WERE THE ROW ID IS BEING INSERTED
                  // WHICH WILL LATER BE USED TO LOAD FORM
                  $tableData .= '&lt;tr id="'.$id.'"&gt;&lt;td&gt;'.$person.'&lt;/td&gt;&lt;td&gt;'.$date.'&lt;/td&gt;&lt;td class="score"&gt;'.$numFormat.'&lt;/td&gt;&lt;td&gt;'.$overall.'&lt;/td&gt;&lt;/tr&gt;';
              $ib++;
          }
      }
      // Send back the tbody HTM
      echo $tableData;
  }else{
      $tableData .= '&lt;tr&gt;&lt;td colspan="4"&gt;&lt;b&gt;YOU MUST SELECT A NAME FROM THE LIST ABOVE!&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p>So I'm not sure if it might be an error in the JS file, or if I should be adding something in the PHP file to generated along with the data that's sent to the ajax request.</p>