-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_contact.html
64 lines (53 loc) · 2 KB
/
edit_contact.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE HTML>
<html>
<head>
<title>Edit contact</title>
<meta charset="utf-8" />
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
//Initialize contact
window.localStorage.setItem("mySurname", "");
window.localStorage.setItem("phoneNumbers", "");
//Action on button click
document.getElementById("EditContact").addEventListener("click", updateContactInfo);
var set_name = document.getElementById("name");
//Get the name of the contact
set_name.value = window.localStorage.getItem("myContact");
function updateContactInfo(contact){
var firstName = document.getElementById("firstname").value;
var lastName = document.getElementById("lastname").value;
var phoneNumbers = document.getElementById("phoneNumbers").value;
var nameObject = new ContactName();
nameObject.givenName = firstName;
nameObject.familyName = lastName;
nameOblect.formatted = firstName + " " + lastName;
contact.name = nameObject;
contact.displayName = firstName + "" + lastName;
var phoneNums = [2];
phoneNums[0] = new ContactField('work', phoneWork, true);
phoneNums[1] = new ContactField('mobile', phoneMobile, true);
contact.phoneNumbers = phoneNums;
contact.save(onUpdateSuccess, onUpdateError);
}
}
function onUpdateSuccess (contact){
alert("Contact successfully updated");
}
function onUpdateError(contactError){
alert("Error in creating updating contact" + contactError.code);
}
</script>
</head>
<body>
<h1>Edit Contact</h1>
<form>
<input type="text" size="20" id="firstname" placeholder="First Name" required/>
<input type="text" size="20" id="lastname" placeholder="Last Name" required/>
<input type="tel" size="20" id="phoneNumbers" placeholder="Phone Number" required/>
<br>
<input type="button" id="EditContact" value="Update Contact"/>
</form>
</body>
</html>