2

以下のコードでは、「右側のボックス」で選択する値 (つまり、1、2、3) を取得しています。

___________      __________

    four   |    |

           |>   |one

    five   |<   |two

           | >> |three

           |<<  |
                __________

コードは次のとおりです。

function Selected()
{

    var menu = document.getElementById('selectedServersID').length;
    alert(menu);
    for (var i=0; i<menu; i++)
    {

        var selectedcol = document.getElementById('selectedServersID')[i].value;
        //var selectedcol = document.getElementById('selectedServersID')[i].innerHTML;
        alert(selectedcol);

    }

}

上記のコードは、右側のボックスにあるすべての値を取得します。ここで、「For ループ」からすべての値を取得し、カンマで区切られた文字列に追加する必要があります。forループの外側で、文字列を作成し、すべての値をカンマで区切って保存する方法は? 助けてください。

4

2 に答える 2