[jQuery] Problems with $('#formID').submit(function(){});
Good afternoon all,
I've run into a bit of a problem that is driving me nuts. Basically
what I'm doing is taking an ASP.NET calculator and translating it into
a javascript calculator, but I've run into a bit of a problem, I can't
seem to capture the form's 'submit'.
Here's the code I'm using:
// Using jQuery-1.2.3
$(document).ready(function() {
$('#totalCost').hide();
$('#spamcalcForm').submit(function() {
// Get the values from the form
var employees = $('#employees').val();
var spamPerDay = $('#spday').val();
var timePerSpam = $('#timespam').val();
var workDays = $('#wrkdays').val();
var avgSalary = $('#salary').val();
// Calculate hours of lost productivity
var hrsLostProd = (employees * spamPerDay * timePerSpam * workDays *
avgSalary / 3600);
// Calculate dollar value of hours of lost producivity
var dollarsLostProd = hrsLostProd * avgAlary / 2000;
// Calculate the cost of spam filter annual subscription
var annual = new annualCost(employees, spamPerDay, timePerSpam,
workDays, avgSalary);
$("#hrsLost").text(hrsLostProd);
$("#dollarsLost").text(dollarsLostProd);
$("#annualSubPrice").text(annual.subscription);
$("#savings").text(annual.savings);
$("#totalCost").show();
});
});
and the form:
<form class="cmxform" id="spamCalcForm" name="spamCalcForm" action=""
method="post">
<fieldset>
<legend></legend>
<ol>
<li>
<label for="employees">Employees:</label>
<input id="employees" name="employees" type="text" size="5"
value="20" />
</li>
<li>
<label for="spday">Spam per day:</label>
<input id="spday" name="spday" type="text" size="5" value="20" />
</li>
<li>
<label for="timespam">Time per spam:</label>
<input id="timespam" name="timespam" type="text" size="5"
value="30" />
</li>
<li>
<label for="wrkdays">Work days:</label>
<input id="wrkdays" name="wrkdays" type="text" size="5"
value="250" />
</li>
<li>
<label for="salary">Avg salary ($):</label>
<input id="salary" name="salary" type="text" size="5"
value="32,000" />
</li>
<li><input type="submit" value="Calculate" id="calc" name="calc" /