、あなたのデータを分割する必要があります:まず
var data = 'Country:-India Port:-AGARTALA,BAGDOGRA,BANGALORE,COIMBATORE';
var portStart = data.lastIndexOf('-')+1;
//create an array of items by removing the garbage in the beginning
//and splitting on the commas
var ports = data.substr(portStart).split(',');
次に、アレイ内のすべてのアイテムを反復するためにjQueryの$.each()
メソッドを使用します。
// ports -> the array from above
// function()... the operation to perform on each item in the array
$.each(ports, function (index, value) {
//insert an option element into #ports with the value/text attributes set as shown
$('#ports').append($('<option/>', {
value: value,
text : value
}));
});
あなたが助けるこの質問のどの部分が必要なのか? – axlj
今、私は既に5カ国とポートを追加しています。現在、ポート名の5行がカンマで区切られた複数のポートを持っています。これですべてのポートをドロップダウンにロードする必要があります。 – sarode111
したがって、データベースへのクエリ、.NETでのオブジェクトへのデータのロード、最後にクライアントへのデータの返送という3つの部分があります。あなたはどこにいるのですか? – axlj