title: JS $('form').change(function() only triggers on first form item
body: <p>Following on from my question yesterday, I now have the code below somewhat successfully working. It allows me to change the first form item and submits it to 'process.php' in the background and turns the field green. However the trigger only works on the first form item, in this case "cstate". It doesn't trigger when "clocation" is changed. If you change clocation and then cstate then both form submit fine so it's simply that the .change function isn't triggering when clocation is changed. I'm not good enough at JS (total JS noob) to know why it isn't working so I'd appreciate any help you can give me.</p>
  
  <p>Thanks!</p>
  
  <pre><code> $sql = "select * from `$table1`";
   $result = mysql_query ($sql) or die(mysql_error());
   while ($row = mysql_fetch_array($result)) 
   { 
     $carid = $row["car_id"]; 
     $carnum = $row["carnum"]; 
     $carlocation = $row["carlocation"];
     $carstate = $row["carstate"];
  
  
    $formname = "#form".$carid;
  
    print '&lt;script type="text/javascript"&gt;';
    print "        var cnum;";
    print "        cnum = '$formname',";
    print "        
  
    $('form').change(function() 
    {
    console.log(cnum);
    $.ajax({ 
    type: 'post',
    url: 'process.php',
    data: $(this).serialize(),
    success: function() {
    }
     });
    return false;
     }); 
    &lt;/script&gt;";
  
     echo "&lt;table&gt;";
     echo "&lt;tr id='$carid'&gt;";
     echo "&lt;td&gt;$carnum&lt;/td&gt;";
     echo "&lt;td&gt;&lt;form action='' method='post' id='form$carid'&gt;";
     echo "&lt;select id='popup' name='cstate'&gt;";
     echo "&lt;option value='In-Service-Bay'&gt;In Service Bay&lt;/option&gt;";
     echo "&lt;option value='Awaiting-Service'&gt;Awaiting Service&lt;/option&gt;";
     echo "&lt;option value='Service-Complete'&gt;Service Complete&lt;/option&gt;";
     echo "&lt;/select&gt;&lt;/td&gt;";
     echo "&lt;select id='popup' name='clocation'&gt;";
     echo "&lt;option value='Carpark-1'&gt;Carpark-1&lt;/option&gt;";
     echo "&lt;option value='Carpark-2'&gt;Carpark-2&lt;/option&gt;";
     echo "&lt;option value='Carpark-3'&gt;Carpark-3&lt;/option&gt;";
     echo "&lt;/select&gt;&lt;/td&gt;";
     echo "&lt;/form&gt;&lt;/tr&gt;";
    }
    echo "&lt;/table&gt;";
  </code></pre>