...

View Full Version : how to have null value if another field is less than a certain number



jackie
07-04-2002, 11:17 PM
I'm coding a PDF form. I have a field that is not always filled in, but when it is, another (calculated) field shows that amount minus twenty. If no value is entered in the first field, -20 is now showing in the calculated field. I would like that calculated value to either show nothing or a zero if an amount less than 20 appears in the first field.

I've played around with the code and I'm completely stuck ... can anyone help me with this please? Thanks.

TrueLies
07-05-2002, 12:28 AM
Hi

well it also depends on how many calculations you have to do.
If you're concerned with only one field, you may just return the function that makes the calculcatiions earlier:

function myCalc(){
return ( isNaN( parseFloat(document.formName.fieldName.value) ) )? "":
document.formName.fieldName.value-20;
}

basically, to check if a field holds a numerical value, aside from regular expressions which are not really neede for just merely numeric formats:

isNaN( parseFloat(VALUEHere) )

it returns true if it is NOT a number, false if it IS a number. You can craft your expressions accordingly.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum