To paraphrase what you ask for: you would like to collect all the input data on the page that meet certain criteria, and then pass them to the api.
A quick look at the API link says makeTransliteratable will accept an array of id strings or an array of elements. Since we do not know the identifiers of the elements in front of the hand, we will pass an array of elements.
So how to get an array of elements?
I will show you two ways: the hard way and the easy way.
First, to get all the text areas, we can do this using the document.getElementsByTagName API:
var textareas = document.getElementsByTagName("textarea");
, , .. type, , :
function selectElementsWithTypeAttribute(elements, type)
{
var results = [];
for (var i = 0; i < elements.length; i++)
{
if (elements[i].getAttribute("type") == type)
{
results.push(elements[i]);
}
}
return results;
}
, :
var inputs = document.getElementsByTagName("input")
var textInputs = selectElementsWithTypeAttribute(textInputs, "text");
, , api:
var allTextBoxes = [].concat(textareas).concat(textInputs);
makeTransliteratable(allTextBoxes, );
, , . jQuery (google it), :
var allTextBoxes = $("input[type='text'], textarea").toArray();
makeTransliteratable(allTextBoxes, );
CSS "" . toArray, , makeTransliteratable.
, ,