There are some different problems here.
1. In the onSubmit trigger you are not specifying the function correctly. It needs to be "mod10CheckDigit()" witht he parens.
2. You are not passing the value to the function. So there is no barcode value to process. You need to either pass the value within the parens of the trigger above or you can grap the value from within the function.
3. The onSubmit trigger is written to expect either a true or false to be returned from the function. You have it so the modDigit is returned. This is used for form validations to return false if the user did not enter a required field or something af that nature and it prevents the form from actually being submitted.
I have corrected the code and added some additional functionality:
<html>
<head>
<title>Check Digiit Calculation</title>
<script type="text/javascript">
function mod10CheckDigit() {
//Get barCode field value, Strip all characters
//except numbers Repopulate field w/ new value
bc = document.barCodeForm.barCode.value
bc = bc.replace(/[^0-9]+/g,'');
document.barCodeForm.barCode.value = bc;
total = 0;
//Get Odd Numbers
for (i=bc.length-1; i>=0; i=i-2) {
total = total + parseInt(bc.substr(i,1));
}
//Get Even Numbers
for (i=bc.length-2; i>=0; i=i-2) {
temp = parseInt(bc.substr(i,1)) * 2;
if (temp > 9) {
tens = Math.floor(temp/10);
ones = temp - (tens*10);
temp = tens + ones;
}
total = total + temp;
}
//Determine the checksum
modDigit = (10 - total % 10) % 10;
//Populate the modDigit field with the value
document.barCodeForm.modDigit.value = modDigit;
return false;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1 align="center">Check Digit Calculation</h1>
<form name="barCodeForm" onSubmit="javascript:return mod10CheckDigit();">
<table width="400" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td width="150" align="right">Number: </td>
<td width="150">
<input name="barCode" type="text" value="123123123" size="18" maxlength="9" id="bc" onKeyDown="this.form.modDigit.value='';">
</td>
</tr>
<tr>
<td width="150" align="right">Mod Digit: </td>
<td width="150">
<input name="modDigit" type="text" value="" size="18" maxlength="9" id="bc" readonly>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="Button" value="Get Check Digit" >
</td>
</tr>
</table>
</form>
</body>
</html>
Michael J