title: jquery button affecting all instances in loop
body: <p>I've got a form that uses jquery/Ajax to update my database without a refresh.
  The jquery fades out the radio options on submit, and then shows another button in case the user would like to change their selection.</p>
  
  <p>My problem is that once the user submits their decisions, if they click the "change your mind" button, the jquery brings back the radios for ALL instances below.</p>
  
  <p>How can that "change your mind" button bring back the radios for ONLY that instance?
  Sorry for the complicated scenario and chunk of code. If you need more info or explanation, just ask!</p>
  
  <p>Thanks.</p>
  
  <pre><code>&lt;? $result = $mysqli-&gt;query("SELECT * FROM items WHERE Job='$job'") or die(mysqli_error($mysqli));
  while( $row = $result-&gt;fetch_assoc() ){ ?&gt;
          &lt;div class='tile'&gt;
  
              &lt;script type="text/javascript"&gt;
                  $('document').ready(function(){
                      $('#form&lt;?= $row['Id'] ?&gt;').ajaxForm({
                          target: '#preview&lt;?= $row['Id'] ?&gt;',
                          success: function() {
                              $('#formbox&lt;?= $row['Id'] ?&gt;').fadeOut('slow'),
                              $('#preview&lt;?= $row['Id'] ?&gt;').fadeIn('slow');
                              $("button").click(function () {
                                  $("#preview&lt;?= $row['Id'] ?&gt;").fadeOut("slow"),
                                  $("#formbox&lt;?= $row['Id'] ?&gt;").fadeIn("slow");});
                          }
                      });
                  });
              &lt;/script&gt; 
  
              &lt;div class='details'&gt;
                  &lt;div id='radios' style='position:relative; height:25px;'&gt;
                      &lt;div id="preview&lt;?= $row['Id'] ?&gt;" style="width:258px; margin-left:-129px; left:50%; display:none; position:absolute;"&gt;
                          &lt;button&gt;Way to go! Click here to change your mind.&lt;/button&gt;
                      &lt;/div&gt;
                      &lt;div id="formbox&lt;?= $row['Id'] ?&gt;" style='position:absolute;'&gt; 
                      &lt;form name='' id='form&lt;?= $row['Id'] ?&gt;' action='js/submit.php' method='post'&gt;
                          &lt;label&gt;Keep:&lt;/label&gt;&lt;input type='radio' name='dec[]' value='keep' &lt;? if($row['Dec1']=='keep'){echo "checked='checked'";} ?&gt; &gt;
                          &lt;label&gt;Donate:&lt;/label&gt;&lt;input type='radio' name='dec[]' value='donate' &lt;? if($row['Dec1']=='donate'){echo "checked='checked'";} ?&gt; &gt;
                          &lt;label&gt;Sell:&lt;/label&gt;&lt;input type='radio' name='dec[]' value='sell' &lt;? if($row['Dec1']=='sell'){echo "checked='checked'";} ?&gt; &gt;
                          &lt;label&gt;Trash:&lt;/label&gt;&lt;input type='radio' name='dec[]' value='trash' &lt;? if($row['Dec1']=='trash'){echo "checked='checked'";} ?&gt; &gt;
                          &lt;label&gt;Give To:&lt;/label&gt;&lt;input type='text' name='dec[]' size='15' &lt;? if($row['Dec1']!='keep' &amp;&amp; $row['Dec1']!='donate' &amp;&amp; $row['Dec1']!='sell' &amp;&amp; $row['Dec1']!='trash'){echo "value='".$row['Dec1']."'";} ?&gt; &gt;
                          &lt;input type='hidden' name='id' value='&lt;?= $row['Id'] ?&gt;' /&gt;
                          &lt;input type="submit" value="Submit"&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;? 
  } 
  </code></pre>