I made a javascript function to find a word in html component and replace it with another word. However, it could do was to insert a button that when clicked invoke the function to replace the words.
I wonder if anyone knows of a way to do this in "run-time" in the case, when you type a word that should be replaced, it be replaced without having to click the button.
Follows the code to find and replace the words:
var texto = document.getElementById("cadastroLaudo:transcript").value;
var novoParagrafo = texto.replace(/novo paragrafo/g, '
');
document.getElementById('cadastroLaudo:transcript').value = novoParagrafo;
My HTML component that will receive the substitution of the word to be found (code below):
<p:inputTextarea id="transcript" name="transcript" rows="8"
cols="60" placeholder="Ditado para Geração de Laudo Médico"
value="#{laudoBean.laudo.texto}" />
And the button that calls the javascript function:
<p:commandButton onclick="formatarTextoLaudo()" value="Formatar" />
In summary, the component is a text box when you type "novo paragrafo" is inserted Enter and the word "novo paragrafo" disappears.
It would be something with Ajax?
Tks!