i have javascript function. i am using that function to translate english language to another language in a text field. as below form when a person type in box01, box02 shows typed english content in translated mode.
<form id="txtBox" action="ps.php" enctype="multipart/form-data" method="post">
<textarea id="box01" onkeyup="startText_sin();" onselect="startText_sin();" onclick="startText_sin();" rows="2" placeholder ="Type in Here"></textarea>
<textarea id="box02" rows="2" placeholder ="Translated"></textarea>
</form>
but i have few of these forms in my single page and the text areas have diffrent names, like bellow,
<textarea id="txt_sin01"></textarea>
<textarea id="txt_trn02"></textarea>
how can i can set function to be work with all of these text areas ?
my function is **startText_sin()**
in function i choose text area like this text = document.getElementById("box01");
any help.
______function________
` //array goes here
function startText_sin() {
var s,r,v;
//text = document.txtBox.box1.value;
text_singlish = document.getElementById("box1_singlish").value;
//special consonents
for (var i=0; i<specialConsonants.length; i++){
text_singlish = text_singlish.replace(specialConsonants[i], specialConsonantsUni[i]);
}
//consonents + special Chars
for (var i=0; i<specialCharUni.length; i++){
for (var j=0;j<consonants.length;j++){
s = consonants[j] + specialChar[i];
v = consonantsUni[j] + specialCharUni[i];
r = new RegExp(s, "g");
text_singlish = text_singlish.replace(r, v);
}
}
//consonants + Rakaransha + vowel modifiers
for (var j=0;j<consonants.length;j++){
for (var i=0;i<vowels.length;i++){
s = consonants[j] + "r" + vowels[i];
v = consonantsUni[j] + "්ර" + vowelModifiersUni[i];
r = new RegExp(s, "g");
text_singlish = text_singlish.replace(r, v);
}
s = consonants[j] + "r";
v = consonantsUni[j] + "්ර";
r = new RegExp(s, "g");
text_singlish = text_singlish.replace(r, v);
}
//consonents + vowel modifiers
for (var i=0;i<consonants.length;i++){
for (var j=0;j<nVowels;j++){
s = consonants[i]+vowels[j];
v = consonantsUni[i] + vowelModifiersUni[j];
r = new RegExp(s, "g");
text_singlish = text_singlish.replace(r, v);
}
}
//consonents + HAL
for (var i=0; i<consonants.length; i++){
r = new RegExp(consonants[i], "g");
text_singlish = text_singlish.replace(r, consonantsUni[i]+"්");
}
//vowels
for (var i=0; i<vowels.length; i++){
r = new RegExp(vowels[i], "g");
text_singlish = text_singlish.replace(r, vowelsUni[i]);
}
document.getElementById("box2_singlish").value=text_singlish; //wirte on page in sihala
}
`