Google AJAX Transliteration API: Is it possible to make all input fields in the page transliteratable?

Rephrasing what you are asking for: you would like to collect together all the inputs on the page which match a certain criteria, and then pass them into an api.

Rephrasing what you are asking for: you would like to collect together all the inputs on the page which match a certain criteria, and then pass them into an api. A quick look at the API reference says that makeTransliteratable will accept an array of id strings or an array of elements. Since we don't know the ids of the elements before hand, we shall pass an array of elements.So, how to get the array of elements?

I'll show you two ways: a hard way and an easy way. First, to get all of the text areas, we can do that using the document. GetElementsByTagName API: var textareas = document.

GetElementsByTagName("textarea"); Getting the list of inputs is slightly harder, since we don't want to include checkboxes, radio buttons etc. We can distinguish them by their type attribute, so lets write a quick function to make that distinction: function selectElementsWithTypeAttribute(elements, type) { var results = ; for (var I = 0; I Length; i++) { if (elementsi. GetAttribute("type") == type) { results. Push(elementsi); } } return results; } Now we can use this function to get the inputs, like this: var inputs = document.

GetElementsByTagName("input") var textInputs = selectElementsWithTypeAttribute(textInputs, "text"); Now that we have references to all of the text boxes, we can concatenate them into one array, and pass that to the api: var allTextBoxes = . Concat(textareas). Concat(textInputs); makeTransliteratable(allTextBoxes, /* options here */); So, this should all work, but we can make it easier with judicious use of library methods.

If you were to download jQuery (google it), then you could write this more compact code instead: var allTextBoxes = $("inputtype='text', textarea").toArray(); makeTransliteratable(allTextBoxes, /* options here */); This uses a CSS selector to find all of the inputs with a type attribute of "text", and all textareas. There is a handy toArray method which puts all of the inputs into an array, ready to pass to makeTransliteratable. I hope this helped, Douglas.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions