passing variables

Giganews Newsgroups
Subject: passing variables
Posted by:  Ed (eyou…@ncsa.uiuc.edu)
Date: Fri, 25 Jul 2003

I need to know how to pass variables because I want to use the same
function to varify multiple data imput boxes.

Please tell me what's wrong with this code.

<head>
<script language="JavaScript">
function myFunction(this){
  entry=document.Forms[0].this.value;
  if (document.Forms[0].this.value==""){
    document.Forms[0].this.focus();
  }
  else {
    // Do something with "entry" here
  }
  if (this = "inputBox2") {
    document.Forms[0].total.value = document.Forms[0].inputBox1.value +
document.Forms[0].inputBox2.value;
    }
}
</script>
</head>
<body>
<form>
<input type="text" name="inputBox1" onBlur="myFunction(this)">
<input type="text" name="inputBox2" onBlur="myFunction(this)">
<input type="text" name="total">
</form>
</body>

Replies