Click here to Skip to main content
16,012,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to mobile development and trying to populate drop down list with country_name
any help would be appreciated.


This is my xml data returned from web services

XML
<NewDataSet>
<script/>
<Table>
<detail>
<country country_sk="2" currency_sk="165" country_name="Afghanistan" country_telecom_code="93  " country_code="AF" /><country country_sk="5" currency_sk="166" country_name="Albania" country_telecom_code="355 " country_code="AL" /><country country_sk="62" currency_sk="167" country_name="Algeria" country_telecom_code="213  " country_code="DZ" /><country country_sk="11" currency_sk="70" country_name="American Samoa" country_telecom_code="1684  " country_code="AS" /><country country_sk="6" currency_sk="213" country_name="Andorra" country_telecom_code="376  " country_code="AD" /><country country_sk="3" currency_sk="169" country_name="Angola" country_telecom_code="244  " country_code="AO" /><country country_sk="4" currency_sk="211" country_name="Anguilla" country_telecom_code="1264  " country_code="AI" />


I am trying to populate country_name in drop down list
with following code but its not working.

<script>
$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://www.xyz.mobwebservice.asmx/countryList",
dataType: "xml",
success: function(xml) {
				var select = $('#mySelect'); 
                 $(xml).find('country').each(function(){
                     var id_text = $(this).attr('country_sk')
                     var name_text = $(this).find('country_name').text()

                     var option = $("<option>" + name + "</option>"); 
                         option.attr("value", value); 
                         select.append(option);
                 }); //close each(
                 	select.children(":first").text("please make a selection").attr("selected", true);
             } //close $.ajax
}); 
}); 
</script>
</head>
<body> 
    <form id="form1"> 
      <select id="mySelect"> 
              <option>loading</option> 
      </select> 
    </form> 
</body>
</html>

help me its very urgent
Posted
Updated 22-May-13 19:49pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900