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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function 1

Status
Not open for further replies.

mickeyg

Technical User
Mar 30, 2001
120
US
I have the following two functions called onBlur:
function UpperD() {
/* CONVERT TEXT TO UPPERCASE */
var myText = document.lineup.D.value;
if(myText == "") {
}
else {
document.lineup.D.value = myText.toUpperCase();
}
}

function UpperK() {
/* CONVERT TEXT TO UPPERCASE */
var myText = document.lineup.K.value;
if(myText == "") {
}
else {
document.lineup.K.value = myText.toUpperCase();
}
}

So far I have unsucessfully tried to reuse one function like the following:
<input type=&quot;text&quot; name=&quot;D&quot; onBlur=&quot;doUpper('D')&quot;>
function doUpper(obj) {
/* CONVERT TEXT TO UPPERCASE */
var myText = document.lineup.obj.value;
if(myText == &quot;&quot;) {
}
else {
document.lineup.obj.value = myText.toUpperCase();
}
}
It tells my that document.lineup.obj.value does not exist. I was expecting obj to be replaced with &quot;D&quot;.

Thanks,
Mickey
 
use the same call but change your function to:
Code:
function doUpper(obj) {
   /* CONVERT TEXT TO UPPERCASE */
   var myText = document.lineup[obj]value;
   if(myText == &quot;&quot;) {
   }
   else {
      document.lineup[obj]value = myText.toUpperCase();
   }
}
or change your fuction to:
Code:
function doUpper(obj) {
   /* CONVERT TEXT TO UPPERCASE */
   var myText = obj.value;
   if(myText == &quot;&quot;) {
   }
   else {
      obj.value = myText.toUpperCase();
   }
}
and your call to:
Code:
<input type=&quot;text&quot; name=&quot;D&quot; onBlur=&quot;doUpper(this)&quot;>
 
Thanks!
One function is so much better!

Mickey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top