A. Following functions compare two single-selection (e.g. combobox) fields' values:
The first function compares both fields and returns true if both numbers are the same.
The second function compares both fields and returns true if the first field/number is greater than the second.
Note: These functions are based off of RCS functions which Marc wrote.
function IsNumsEqual(field1, field2, msg) {
// verifies that value of field1 is same as value of field2
// assumes both are numbers or convertable to numbers
// change to !== to enforce same datatype
if ( Number(field1[field1.selectedIndex].value) != Number(field2[field2.selectedIndex].value) ) {
field1.className="error";
errorMsgs += msg + "\n\r";
field1.focus();
return false;
}
return true;
}
function IsNumGreater(field1, field2, msg) {
// verifies if field1 is greater than value of field2
// assumes both are numbers or convertable to numbers
// change to !== to enforce same datatype
if ( Number(field1[field1.selectedIndex].text) <= Number(field2[field2.selectedIndex].text) ) {
field1.className="error";
errorMsgs += msg + "\n\r";
field1.focus();
return false;
}
return true;
}
function IsNumGreater(field, numval1, numval2, msg) {
// verifies that value of field2 is greater than or equal to value of field1
// assumes both are numbers or convertable to numbers
// change to !== to enforce same datatype
num1 = Number(numval1);
num2 = Number(numval2);
if ( num1 > num2 ) {
field.className="error";
errorMsgs += msg + "\n\r";
field.focus();
return false;
}
return true;
}
B. Following function allows Javascript to update combox options based some other field's value:
ChangeComboBoxOptions.txt
previous page
|