2015-04-28 71 views

回答

5

我建議使用:

https://github.com/umpirsky/country-list

它可以讓你以不同的格式的國家名單(文字,JSON,PHP ...)

或者,如果你想只是一個快速的HTML列表,然後去:

http://www.textfixer.com/resources/country-dropdowns.php

你可以從字面上只需將這些值複製粘貼到您想要的任何位置,或者您可以調用該頁面。

+0

非常感謝你kamal。 –

+0

好卡邁勒我需要插入數據庫中的所有國家,因爲我必須在PHP中使用它? –

0

在Struts2你可以得到它 - 例如,

<s:select name="name" headerKey="-1" 
list="countryList" id="country" 
value="%{countryList}" 
></s:select> 

在jQuery中,你將有通過一個AJAX調用來獲取列表,並遍歷它 例如,

$.ajax({ 
      url: 'rcmidAuditTrail.action', 
      type: 'GET', 
      async : false, 
      dataType: 'json', 
      error: function(data) { 
       console.log('error'); 
      }, 
      success: function(list) { 

var html = '<select>' 
       $.each(list,function(i,value){ 
        html+='<option>'+value+'</option>'; 
       }); 
$('dropdownId').html(html); 
      } 
     }); 
+0

謝謝你waqar –

相關問題