title: Multiple star rating forms in a single page
body: <p>I have a home.php page in which I load posts with an Ajax function from load_posts.php
  This is the important code of load_posts.php:</p>
  <pre><code>...
  $userid = $_POST['userid'];
  $sql = mysqli_query($conn, &quot;SELECT * FROM storie WHERE userid IN (SELECT following FROM follow WHERE follower='$userid')&quot;);
  while($row = mysqli_fetch_assoc($sql)){
  $idsto=$row['storia_id'];
  ...
  ?&gt;
  &lt;div class=&quot;storia&quot; id=&quot;storia_&lt;?php echo $idsto;?&gt;&quot;&gt;
  ...
  &lt;div class=&quot;star-rating&quot;&gt;
        &lt;input id=&quot;star-5&quot; type=&quot;radio&quot; name=&quot;rating&quot; value=&quot;5&quot; class=&quot;stellette&quot; /&gt;
        &lt;label for=&quot;star-5&quot; title=&quot;5 stars&quot;&gt;
          &lt;i class=&quot;active fa fa-star fa-sm&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;
        &lt;/label&gt;
        &lt;input id=&quot;star-4&quot; type=&quot;radio&quot; name=&quot;rating&quot; value=&quot;4&quot; class=&quot;stellette&quot;/&gt;
        &lt;label for=&quot;star-4&quot; title=&quot;4 stars&quot;&gt;
          &lt;i class=&quot;active fa fa-star fa-sm&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;
        &lt;/label&gt;
        &lt;input id=&quot;star-3&quot; type=&quot;radio&quot; name=&quot;rating&quot; value=&quot;3&quot; class=&quot;stellette&quot;/&gt;
        &lt;label for=&quot;star-3&quot; title=&quot;3 stars&quot;&gt;
          &lt;i class=&quot;active fa fa-star fa-sm&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;
        &lt;/label&gt;
        &lt;input id=&quot;star-2&quot; type=&quot;radio&quot; name=&quot;rating&quot; value=&quot;2&quot; class=&quot;stellette&quot;/&gt;
        &lt;label for=&quot;star-2&quot; title=&quot;2 stars&quot;&gt;
          &lt;i class=&quot;active fa fa-star fa-sm&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;
        &lt;/label&gt;
        &lt;input id=&quot;star-1&quot; type=&quot;radio&quot; name=&quot;rating&quot; value=&quot;1&quot; class=&quot;stellette&quot;/&gt;
        &lt;label for=&quot;star-1&quot; title=&quot;1 star&quot;&gt;
          &lt;i class=&quot;active fa fa-star fa-sm&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;
        &lt;/label&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php
  }
  ?&gt;
  </code></pre>
  <p>I'd like to have two jQuery variables, one with the value of the $idsto rating, and the other with the rating checked value from 1 to 5.</p>
  <p>When I have only one single rating in a page, I simply do this:</p>
  <pre><code>$('input[name=rating]').change(function(){
  var voto = $( 'input[name=rating]:checked' ).val();
  </code></pre>
  <p>But now I don't know how to get the specific rating of the id $idsto.
  I tried writing this, but with no results:</p>
  <pre><code>$(&quot;input[name^='rating']&quot;).change(function(){
  ...
  name=&quot;rating_&lt;?php echo $idsto;?&gt;&quot;
  </code></pre>
  <p>Can anyone help me?</p>