ajax success div with same name problem

ajax success div with same name problem

I have a while loop writing rows from the database as separate forms on a page.  Works fine.  It writes a hidden div just before each closing form tag.  They all have same div id.  I call a success function that fills in this hidden div with a success messages.  Problem is no matter what form I choose the output always gets written to the first form on the page.  I have to somehow determine what form was clicked and then tell the success function to use that div name.  Not sure how to go about that.

  1. <form>
  2. <input type="radio" name="contract" value="0" class="custom-switch-input">
  3. <input type="radio" name="contract" value="1" class="custom-switch-input">
  4. <input type="radio" name="contract" value="2" class="custom-switch-input">

  5. <div class="alert alert-icon alert-success" role="alert" id="output" style="display: none">
  6. <i class="fe fe-check mr-2" aria-hidden="true" ></i> The contract status has been updated successfully.</div>
  7. </form>

  8. $(document).ajaxSuccess(function()
  9. {
  10. $("#output").fadeTo(4000, 500).slideUp(500, function(){
  11.         $("#output").slideUp(500);

  12.      });
  13.  });