title: How to get a value you got from onclick event function to javascript function
body: <p>My problem is I have an HTML object -> <code>&lt;button&gt;&lt;/button&gt;</code> and inside this button is an onclick 
  event that calls a function that that gets a variable from the location where the button is: </p>
  
  <pre><code>&lt;button onclick="myFunction(myVariable)"&gt;&lt;/button&gt;
  </code></pre>
  
  <p>However I want to use myVariable in myFunction().<br>
  I already tried something like this:</p>
  
  <pre><code>function myFunction(myVariable){
     alert(myVariable);
  }
  </code></pre>
  
  <p>But I only get objecthtmlbuttonelement as alert..</p>
  
  <p>Hope you can help me guys, thanks!</p>
  
  <p>//for better understanding i'll add my code in:</p>
  
  <pre><code>function displayProducts(){
      //var sum = 0; 
      sum = 0;
          db.transaction(function(tx){
              tx.executeSql("SELECT * FROM products",[], function(tx,results){
                  len = results.rows.length;
                  var stuff = "&lt;div id='products'&gt;";
  
                  for (var i=0; i&lt;len; i++){
                      var products_all = results.rows.item(i).p_name; //the variable
                      var price = results.rows.item(i).price;
                      if(i%4==0){
                          stuff += "&lt;br/&gt;";
                      }
                      var izdelki = "&lt;div id='izpis_izdelkov'&gt;";
  
                      //here's the button element
                      stuff += "&lt;button class='pivo'  id='"+products_all+"' onclick='Calculate("+products_all+");' name='"+products_all+"' value='"+price+"'&gt;"+products_all+'&lt;/button&gt;';
  
  
                  }
                  $('#stuff').html(stuff + "&lt;/div&gt;");
                  $('#izd').html(izdelki + "&lt;/div&gt;");
              });
          });
      }
  </code></pre>
  
  <p>//the function I want to use the variable</p>
  
  <pre><code>function Calculate(products_all){
      alert(products_all);
  }
  </code></pre>