OK, I have a form that needs to be pre-populated with values from a database and then those values (or updated values if they have changed) need to be inserted back into the db. I can pull the data and write the data just fine, the problem comes in when I want to change the data to write it back to the db. It is a form to collect numbers for conferences, just numbers of boys and girls, very simple, so if the group numbers change, they can update their record. I have this code to calculate a total
and then this sample for a form field
The problem I am having is that the numbers update and recalculate correctly on the page, but when I submit the data or look at the source code after making the changes, it has the initial values so no changes are being made. What am I missing?
Thanks for any fresh eyes you can give to me!
WB
Code:
<script language="JavaScript" type="text/javascript">
function calculate(el)
{
var form = el.form;
var male_students = Number(form.elements["male_students"].value );
var female_students = Number(form.elements["female_students"].value );
var male_adults = Number(form.elements["male_adults"].value );
var female_adults = Number(form.elements["female_adults"].value );
var total = male_students + female_students + male_adults + female_adults;
// Check for user entry errors
if (isNaN(total)) {
// Alert user of error
alert("Please enter only numbers");
} else {
// Show total in the form field, and select the form field text
form.elements["total"].value = total;
//form.elements["total"].select();
}
}
</script>
and then this sample for a form field
Code:
<input name="male_students" type="text" id="male_students" size="3" value="<%=ms%>" onchange="calculate(this)">
The problem I am having is that the numbers update and recalculate correctly on the page, but when I submit the data or look at the source code after making the changes, it has the initial values so no changes are being made. What am I missing?
Thanks for any fresh eyes you can give to me!
WB