1

電話番号を含む csv ファイルを HTML の複数選択ボックスにインポートしたいと考えています。jqueryまたはajaxで可能ですか?誰でも助けてください。

ありがとう

4

1 に答える 1

2

このようなもの:

//jquery ajax function, calls a file (url), if it succeds, the "success" happens, "data" is the contents of the file
$.ajax({
    url: 'path_to_your_file',
    success: function(data) {
        //splitting the data by commas (i presume that with csv you mean comma seperated values file)
        var splitData=data.split(",");
        //looping through the data
        for(pn in splitData){
            //current phone number is stored in "pn", appending a new option with value of the current phone number to the multiple select box with id "select_id"
            $('#select_id').append("<option value=\""+pn+"\">"+pn+"</option>");
        }
    }
});
于 2012-09-19T13:11:55.153 に答える