title: Pass values ​MySQL query using javascript
body: <p>When making a query, I show the results in a table, each row has a button. By pressing it I move the information of the selected row to a textarea. The problem is that when all the buttons have the same identifier, java always takes the first row.</p>
  <p><a href="https://jsfiddle.net/a50ue2bw/" rel="nofollow noreferrer">https://jsfiddle.net/a50ue2bw/</a></p>
  <pre class="lang-js prettyprint-override"><code>function calcular() {
      $('#pedido').val($('#pedido').val() + $(this).closest('tr').find('#cantidad').val());
      $('#pedido').val($('#pedido').val() + &quot; &quot;+ $(this).closest('tr').find('select option:selected').attr('value'));
      $('#pedido').val($('#pedido').val() + &quot; &quot;+ $(this).attr('nombre')+ &quot;\n&quot;);
      
      var newPrice = parseFloat($('body').find('#categoria option:selected').attr('precio'));
      var cantidadt = parseFloat($('body').find('#cantidad').val());
      $(&quot;#cuenta&quot;).val(parseFloat($(&quot;#cuenta&quot;).val())+parseFloat(newPrice*cantidadt)+' €');
      $(&quot;#save&quot;).val(parseFloat($(&quot;#save&quot;).val())+parseFloat(newPrice*cantidadt));
  }
  </code></pre>