PDA

Click to See Complete Forum and Search --> : Add 2 fields


venerable bede
Jul 22nd, 2003, 04:26 AM
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 ?

venerable bede
Jul 22nd, 2003, 07:44 AM
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.:mad:

mendhak
Jul 22nd, 2003, 10:43 AM
http://www.experts-exchange.com/Developer/Web/Web_Languages/JavaScript/Q_20668658.html

Derive your needs from there, you choleric oaf.

venerable bede
Jul 22nd, 2003, 10:54 AM
Forth with oh green slimy one.;)