Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

one event two functions 1

Status
Not open for further replies.

ttuser4

MIS
Jun 19, 2008
147
CA
hi, i need to call two functions for a textbox on onkeyup event

function data_change(field)
{
var check = true;
var value = field.value; //get characters
for(var i=0;i < field.value.length; ++i)
{
var new_key = value.charAt(i); //cycle through characters
if(((new_key < "0") || (new_key > "9")) &&
!(new_key == ""))
{
check = false;
break;
}
}
if(!check)
{
field.style.backgroundColor = "red";
}
else
{
field.style.backgroundColor = "white";
}
}

function f2m(form)
{
var f = parseFloat(form.tlength.value);
var m = "";
if (!isNaN(f)) m = Math.round(f * 0.3048* 100)/100;
form.lm.value = m;
}

data_change(field) is also used by other textboxes, function f2m(form) is used only by one textbox.

i already tried combine them like onkeyup="return(data_change(this)&&f2m(this.form));"

any help please?
 
separate the two by a semi-colon:

Code:
<input type="text" onKeyUp="myFirstFuntion(params);mySecondFunction(params)" />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top