Script says Undefined
- by user1058887
I have this script that would let the user input a text and it would get translated into something else. It works only when the word has only 1 letter. When there is more than 1 letter it says Undefined.
Here is the script :
function copyit(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")
}
function results()
{
var behavior="form";
var text=document.csrAlpha.csrresult2.value;
var ff22=text.toLowerCase();
var Words=new Array ;
Words["b"]="Dadada";
Words["bob"]="Robert";
Words["flower"]="Banana";
Words["brad"]="Chair";
var trans="";
var regExp=/[\!@#$%^&*(),=";:\/]/;
var stringCheck=regExp.exec(ff22);
if(!stringCheck)
{
if(ff22.length > 0)
{
for(var i=0;i < ff22.length;i++)
{
var thisChar=ff22.charAt(i);
trans += Words[thisChar] + " ";
}
}
else
{
trans +="Please write something.";
}
}
else
{
trans +="You entered invalid characters. Remove them and try again.";
}
document.csrAlpha.csrresult.value=trans;
}
Please insert your text
below: