title: Play Framework 2.4: Getting the id of a button
body: <p>I have the following form with repeating items:</p>
  
  <pre><code> @(adverts: List[models.AdvertModel])
   @if(adverts.size() &gt; 0 &amp;&amp; adverts != null) {
      @helper.form(action = routes.UserController.editAdvert()) {
          @for( (advert, index) &lt;- adverts zip (Stream from 0)) {
              &lt;div&gt;@adverts.get(index).title&lt;/div&gt;
              &lt;button type="submit" name="delete" id="delete_@index"&gt;delete&lt;/button&gt;    
  
          }
       }
  </code></pre>
  
  <p>and this controller:</p>
  
  <pre><code>    public Result editAdvert() {
      String[] indices =   request().body().asFormUrlEncoded().get("delete");
      if (indices != null) {
          // delete advert
          }
      return ok();
  }
  </code></pre>
  
  <p>I would like to be able to delete adverts according to their ids but with the current code my array contains a String <code>"delete"</code> instead of i.e.  <code>"delete_0"</code>.
  How do I get the index of the clicked button?</p>