javascript - Show contact list using phonegap -


i using phonegap sample application list contacts names, unable so. below onsuccess() function. getting found 7 contacts message in second line of function. showing of results trials in getting name.

function onsuccess(contacts) {     navigator.notification.alert('found ' + contacts.length + ' contacts.');     var con = document.getelementbyid('con');      (var = 0; < contacts.length; i++) {        navigator.notification.alert(contacts[i].name);     }  }; 

trials :

  <br/>   1). navigator.notification.alert(contacts[i])<br/>   result ->   {"id":"0","displayname":"andrew hill","nickname":"andrew hill",   "phonenumbers":["(206)5550001"],"emails":["andy@fai=urthcoffee.com"],   "addresses":["microsoft.phone.userdata.contactaddress"],   "urls":["www.fourthcoffee..com"]}    , in same foramt other 6 contacts.    2). navigator.notification.alert(contacts[i].name)<br/>   result ->   message    same all.    3). navigator.notification.alert(contacts[i].name[i].value)<br/>   result ->   shows nothing. 

please me in getting name field. in advance

well, have not tested windows phone 7 working fine ios/android, tested on device , simulator both.

navigator.contacts.find(     ['displayname', 'name','phonenumbers'],     function(contacts){         var contact_name;         var contact_phone;         for( = 0; < contacts.length; i++) {             if(contacts[i].name.formatted != null && contacts[i].name.formatted != undefined ) {                 contact_name = contacts[i].name.formatted;                 contact_name = contact_name.replace(/'/g,"''");                 if(contacts[i].phonenumbers != null && contacts[i].phonenumbers.length > 0 && contacts[i].phonenumbers[0].value != null && contacts[i].phonenumbers[0].value != undefined ) {                     console.log( contacts[i].phonenumbers[0].value );                     contact_phone = contacts[i].phonenumbers[0].value;                 } else {                     console.log( "--no number-" );                     contact_phone = "";                 }             }         }     },function(error){         alert(error);     },{ filter:"", multiple:true } ); 

Comments