jQuery HTML Button fires function multiple times

Xashi

New Member
I'm creating an HTML form that displays a column of checkboxes, click on submit and the event will be picked up by a jQuery function. However, after examining the function in the Firebug net panel, I've noticed that the function fires multiple times even if I click the button just once! Any idea why?HTML: \[code\]echo "<form id='massHoursSubtraction'>";echo "How many hours to subtract? <input type='text' name='hours'><br />";$entries = 1;while($row = mysql_fetch_array($members)) { $studentID = $row['studentid']; echo "<input type='checkbox' name='studentID[]' id='' value='http://stackoverflow.com/questions/15860066/$studentID'>$studentID"; echo "<br />"; $entries++;}echo "<input type='button' id='submitValues' value='http://stackoverflow.com/questions/15860066/Submit' onclick='javascript:getHours($entries);' />";echo "</form>";\[/code\]Javascript: \[code\]function getHours(numberOfEntries) {$(document).ready(function() { $("#submitValues").click(function(){ var str = $("#massHoursSubtraction").serialize(); alert("How many times?"); $.post("output.php", str); });});}\[/code\]Here's a screenshot of the Firebug net panel: http://imgur.com/Z83s5frThis is the \[code\]$_POST\[/code\] string: \[code\]hours=1&studentID%5B%5D=5112244\[/code\]
 
Back
Top