Building an Address Book > Creating the Application Functions > The doRemoveContact() Function |
![]() ![]() ![]() |
The doRemoveContact() Function
The doRemoveContact()
function deletes a contact from both the local SharedObject
and the contactListBox_lb
. It is invoked by the "Remove Contact" PushButton.
The doRemoveContact()
function performs the following tasks:
![]() |
Determines which contact to remove (by checking |
![]() |
Removes the contact from the local |
![]() |
Repopulates the contact ListBox. |
The complete listing for doRemoveContact()
is shown below. There
are no new techniques in the code. Study the comments to learn how the function
works.
/* * Function: doRemoveContact() * Desc: Removes a contact from the local shared object and * from the contacts listbox. * Parameters: None. */ function doRemoveContact () { // Retrieve the data value of the selected listbox item. This // will be a contact id number. var selectedID = contactListBox_lb.getValue(); // Delete the selected contact. contactMgr.removeContact(selectedID); // Refill the entries in the address book. populateListBox(); // Update the contact details pane (this clears the // pane because no item has focus in the list box). populateDetailsPane(); }
![]() ![]() ![]() |