Aleks Kpur Aleks Kpur - 9 months ago 31
jQuery Question

HTML/Javascript - Button onClick calling function with variables

So I have an online store, I have an button which calls a function called

, but in Javascript this function has
purchase(name, amount)
. So, you can put name easily, in the onclick function
, but my problem is how I could put the amount? Amount is being chosen from the

I created somekind of JSFiddle as well, so you can take a look:


Using jquery you could do this;

 <button class="button" onclick="payment('milk', $('select').val())">$1.85</button>