Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to have null value if another field is less than a certain number

    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.

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Alberto http://www.unitedscripters.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •