私はこれが必要です、それは分割して再び参加するようなオプションを追加できますか私はこれの多くを知りませんが、そのオプションを持つアクションスクリプトを見ましたそれは「a、b、c」でしたjavascriptでそれが欲しい私がそれを手に入れるのを手伝ってください...
tIn.onChanged = function()
{
var sInput = tIn.text; //Gets the text from the first text field.
sInput = translate(sInput); //Goes through the translator.
tOut.text = sInput; //Sets the second text field to the translated text.
}
function translate(sInput)
{
//This is where you add how you want your text changed.
//It should be in the format of
//sInput = searchAndReplace(sInput, What you want changed, What you want it changed to);
//Remember to use quotes around the text you are changing.
sInput = searchAndReplace(sInput, "how r u sis", "how are you sister ");
sInput = searchAndReplace(sInput, "how r u bro", "how are you brother ");
sInput = searchAndReplace(sInput, "whatsup ", "what is up ");
return sInput;
}
function searchAndReplace(a, b, c) //Searches string a for b and replaces it with c
{
tmp = a.split(b); //Splits a into an array of values where b is.
a = tmp.join(c); //Joins them back together with c seperating them.
return (a); //Returns the changed string.
}
まず...入力中にスクリプトを実行したい場合は、「検索」ボタンを追加する理由はありません。とにかく、ここに入力フィールド(入力時)と検索ボタンのコードがあり、使用したいものを選択しました:
<input id="sInput" type="text" onkeydown="translate()">
<input type="button" value="Search" onClick="translate()">
このコードの後、およびdivの「結果」の後、javascriptコードを追加する必要があります。
<script type="text/javascript">
function translate()
{
var sInput = document.getElementById('sInput').value;
sInput = sInput.split("how r u sis").join("how are you sister ").split("how r u bro").join("how are you brother ").split("whatsup ").join("what is up ");
document.getElementById('result').innerHTML =sInput;
}
</script>
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加