アクションスクリプトからJavaスクリプト-文字列から文字列への変換

OmarTeacher

私はこれが必要です、それは分割して再び参加するようなオプションを追加できますか私はこれの多くを知りませんが、そのオプションを持つアクションスクリプトを見ましたそれは「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]

編集
0

コメントを追加

0

関連記事

分類Dev

文字列から文字配列、int配列、リンクリストへの変換

分類Dev

パインスクリプトシリーズ[文字列]から文字列への変換

分類Dev

文字から文字列への変換Ada

分類Dev

配列から文字列への変換

分類Dev

配列から文字列への変換

分類Dev

Java文字列からJSONへの変換

分類Dev

Javaでの文字列から文字列への配列変換

分類Dev

文字列のリストからタプルのリストへのPython変換

分類Dev

BufferedInputStreamから文字列への変換?

分類Dev

Javascript文字列からintへの変換

分類Dev

文字列からintへの型変換

分類Dev

URIから文字列への変換

分類Dev

Swift文字列からconstchar *への変換

分類Dev

文字列からIvalueへの変換

分類Dev

文字列から数値への変換

分類Dev

文字列から数値への変換

分類Dev

文字列からDateFormatへの変換

分類Dev

日時から文字列への変換

分類Dev

文字列から日付への変換

分類Dev

MIPS文字列から整数への変換

分類Dev

PHP strlen()から文字列への変換

分類Dev

Gsonからjsonへの文字列変換

分類Dev

Ruby:文字列から整数への変換

分類Dev

Python 文字列から dateTime への変換

分類Dev

jooq 文字列から整数への変換

分類Dev

Python 文字列から整数への変換

分類Dev

Python:整数から文字列への変換

分類Dev

Json文字列からDatatableへの変換

分類Dev

Pythonでの文字列から文字列配列への変換