Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I created an address book where the user enters the name, phone and email in the input field. This is stored in a array/ list

I created an address book where the user enters the name, phone and email in the input field. This is stored in a array/ list that adds up and shows it in a table below. How can I use a search box to filter the list? I want to filter on name, phone number and email and Filtering is case-insensitive.

and Add a settings panel that is hidden by default and is shown by clicking a button or link. The user can customize the appearance of the list, for example, change the font family and size for the different fields (name, tel, email), from predefined lists.

here's my code:

HTML:

Add entry

Name Tel Email

Javascript:

var Rows = null

function Form() {

var formData = readFormData();

if (Rows == null)

insertNewRecord(formData);

else

updateRecord(formData);

resetForm();

}

function readFormData() {

var formData = [];

formData["name"] = document.getElementById("name").value;

formData["tel"] = document.getElementById("tel").value;

formData["email"] = document.getElementById("email").value;

return formData;

}

function insertNewRecord(data) {

var table = document.getElementById("MyList").getElementsByTagName('tbody')[0];

var newRow = table.insertRow(table.length);

cell1 = newRow.insertCell(0);

cell1.innerHTML = data.name;

cell2 = newRow.insertCell(1);

cell2.innerHTML = data.tel;

cell3 = newRow.insertCell(2);

cell3.innerHTML = data.email;

cell4 = newRow.insertCell(3);

cell4.innerHTML = `Edit

Delete`;

}

function insert(){

var table = document.getElementById("MyList").getElementsByTagName('tbody')[0];

var newRow = table.insertRow(table.length);

cell1 = newRow.insertCell(0);

cell1.innerHTML = "Nina";

cell2 = newRow.insertCell(1);

cell2.innerHTML = "48569244";

cell3 = newRow.insertCell(2);

cell3.innerHTML = "example";

cell4 = newRow.insertCell(3);

cell4.innerHTML = `Edit

Delete`;

var newRow = table.insertRow(table.length);

cell1 = newRow.insertCell(0);

cell1.innerHTML = "harald";

cell2 = newRow.insertCell(1);

cell2.innerHTML = "98569144";

cell3 = newRow.insertCell(2);

cell3.innerHTML = "example email";

cell4 = newRow.insertCell(3);

cell4.innerHTML = `Edit

Delete`;

var newRow = table.insertRow(table.length);

cell1 = newRow.insertCell(0);

cell1.innerHTML = "susanne";

cell2 = newRow.insertCell(1);

cell2.innerHTML = "45625894";

cell3 = newRow.insertCell(2);

cell3.innerHTML = "example mail";

cell4 = newRow.insertCell(3);

cell4.innerHTML = `Edit

Delete`;

}

function resetForm() {

document.getElementById("name").value = "";

document.getElementById("tel").value = "";

document.getElementById("email").value = "";

selectedRow = null;

}

function Edit(td) {

selectedRow = td.parentElement.parentElement;

document.getElementById("name").value = selectedRow.cells[0].innerHTML;

document.getElementById("tel").value = selectedRow.cells[1].innerHTML;

document.getElementById("email").value = selectedRow.cells[2].innerHTML;

}

function updateRecord(formData) {

selectedRow.cells[0].innerHTML = formData.name;

selectedRow.cells[1].innerHTML = formData.tel;

selectedRow.cells[2].innerHTML = formData.email;

}

function Delete(td) {

if (confirm('Do you want to delete it?')) {

row = td.parentElement.parentElement;

document.getElementById("MyList").deleteRow(row.rowIndex);

resetForm();

}}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

U11 Informing Industry: Publicizing Contract Actions 317

Answered: 1 week ago

Question

1. Describe the power of nonverbal communication

Answered: 1 week ago