cordova - How to get device contact number list from Jquery PhoneGap app -


i trying create contact retrieving form in jquery mobile - phonegap app. wanted search contact name , place number of result contact input field. have worked on since yesterday still not make work. --- phonegap version 2.9.0

this code

$('#findcontactbtn').click(function(){  var options = new contactfindoptions(); options.filter = "";       options.multiple = true;    filter = $('#namefield').value(),   navigator.contacts.find(filter, onsuccess, onerror, options);    })  function onsuccess(contacts) { (var i=0; i<contacts.length; i++) { //return result number here $('#messagenumber').attr('value', contact[0].phonenumbers[0].value);   } };    function onerror(contacterror) { alert('onerror!'); }        

html

<div data-role="content">   <label for="namefield">search contact</label>   <input type="search" name="namefield" id="namefield" value=""  />   <input type="submit" value="send message" id="findcontactbtn" />     <label for="messagenumber">number:</label>   <input type="tel" name="messagenumber" id="messagenumber" value=""  />    </div> 

i really glad if can of help, thank you

first of install plugin https://github.com/apache/cordova-plugin-contacts

than go page need list , write code

  document.addeventlistener("deviceready", ondeviceready, false);         function ondeviceready() {             var options = new contactfindoptions();            options.filter="";            options.multiple=true;            var fields = ["*"];           navigator.contacts.find(fields, onsuccess, onerror, options);         }         //on success handler         function onsuccess(contacts)         {            (var = 0; < contacts.length; i++)             {               $("#contactlist").append("<li>"+contacts[i].phonenumber[0].value+"</li>");               $("#contactlist").listview("refresh");             }         }     //error handler         function onerror()         {           alert("some error occured");         }   </code> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -