Results 1 to 4 of 4

Thread: Add 2 fields

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Add 2 fields

    I know this is going to sound daft but I aint a javascript man.

    I have 3 fields on a form f1, f2 and f3.
    When the user leaves f1 or f2 I need to first check to see if it is a
    numeric type then add f1 and f2 together and place the answer in the f3
    field.

    Can anyone help ?

    Parksie

  2. #2

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Actually its three fields.

    e.g

    function sum_it(textbox) {
    if ((textbox.value.indexOf('0') == -1) && (textbox.value.indexOf("1") == -1) &&
    (textbox.value.indexOf("2") == -1) && (textbox.value.indexOf("3") == -1) &&
    (textbox.value.indexOf("4") == -1) && (textbox.value.indexOf("5") == -1) &&
    (textbox.value.indexOf("6") == -1) && (textbox.value.indexOf("7") == -1) &&
    (textbox.value.indexOf("8") == -1) && (textbox.value.indexOf("9") == -1) ) {
    alert("You must enter only numbers");
    return;
    }

    var tot1 = (parseInt(document.form1.txtProceeds.value)) + (parseInt(document.form1.txtCashProvided.value));
    var tot2 = tot1 + (parseInt(document.form1.txtPurchasePrice.value));
    document.form1.txtBalance.value = tot2.toString();

    }


    I am sick of this. Im gonna go and catch Malaria just for the hell of it.

    Parksie

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    http://www.experts-exchange.com/Deve..._20668658.html

    Derive your needs from there, you choleric oaf.

  4. #4

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Forth with oh green slimy one.

    Parksie

Posting Permissions

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



Click Here to Expand Forum to Full Width