Script says Undefined
Posted
by
user1058887
on Stack Overflow
See other posts from Stack Overflow
or by user1058887
Published on 2011-11-22T01:47:20Z
Indexed on
2011/11/22
1:50 UTC
Read the original article
Hit count: 219
JavaScript
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:
© Stack Overflow or respective owner