title: get radio button value (PhP MySQL and ajax)
body: <p>Newbie here..
  I have this code for my displaying the database records in a table,
  I want to know how do i get the value of radio button (the radio button contains the id of selected row). I tried doing it in javascript but no luck.</p>
  
  <p>table.php</p>
  
  <pre><code>&lt;table border="1"&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Particulars&lt;/th&gt;
      &lt;th&gt;Amount&lt;/th&gt;
  
          &lt;?php
              include('includes/config.php');
              $qry = $con-&gt;prepare('SELECT * FROM fees');
              $qry-&gt;execute();
              $row = $qry-&gt;rowCount();
  
              while ($row = $qry-&gt;fetch(PDO::FETCH_ASSOC)) {
                  $id = $row['fee_id'];
                  $fee = $row['fee_name'];
                  $amt = $row['amount'];                      
          ?&gt;
          &lt;?php echo "
  
          &lt;tr title='Click to edit or delete record'&gt;
             &lt;td&gt;&lt;input type = 'radio' name = 'radio' class ='radio' value = $row[fee_id]&gt;&lt;/td&gt;
             &lt;td&gt;$fee&lt;/td&gt;
             &lt;td&gt;$amt&lt;/td&gt;                            
          &lt;/tr&gt;
  
          "; ?&gt;
          &lt;?php } ?&gt;      
  &lt;/table&gt;
  &lt;input type="button" value="Delete Selected Fee" style="width:250px; height:40px;font-weight:bold;" onclick="delete();"&gt;&lt;br&gt;&lt;br&gt;
  </code></pre>
  
  <p>javascript code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          function delete(){
          if (document.getElementsByClassName(this.class).checked){
              var val = document.getElementsByClassName(this.class).value;
              alert (val);
              }
          }
  
  &lt;/script&gt;
  </code></pre>