Reference no: EM131277207
Use the code for customers to create a single page web application that starts by initializing all eh customers. The page should present a menu that allows the user to view all customers, search for a customer based on name, phone or email, add a customer or delete a customer.
Customer fields are:
name, address, phone, email
We can use a separate JavaScript file for your code or write your code on the same HTML page.
For view all customers, we can show the customers either in an HTML table or in an alert.
Inputs can be done using prompts and confirm.
For add, delete, search and view, we need to write separate functions. If you like, you can come check with the Professor what the function signatures would look like, before you write the code for each functions.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>HTML</title>
<meta name="description" content="">
<meta name="author" content="akhilesh-bajaj">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
</head>
<body>
<div>
<header>
<h1>HTML</h1>
</header>
<div>
<script>
function oneDummyCust() {
//returns one dummy cust as an associative array object
var customer = [];
customer["name"] = "XXXXXXX";
customer["address"] = "XXXXXXX";
customer["email"] = "XXXXXXX";
return customer;
}//oneDummyCust
function initCustomers(s_par) {
//returns an initialized array of dummy customers
var customers = [];
for(var i = 0; i < s_par; i++) {
customers[i] = oneDummyCust();
}//for
return customers;
}//init
function printCustomers(customers_par) {
//prints customers in the array that is passed in
var allCustomers = "";
//string that will hold all customers info
for(var i = 0; i < customers_par.length; i++) {
allCustomers += "Customer " + i + "\n" + customers_par[i]["name"] + "\n" + customers_par[i]["address"] + "\n" + customers_par[i]["email"] + "\n" + "\n";
}//for
alert(allCustomers);
}//printCustomers
function printMenu() {
//prints menu and returns a valid choice
var menuString = "1. Add A Customer \n 2. Quit"
for(; ; ) {
var choice = parseInt(prompt(menuString));
if((choice == 1 || choice == 2))
break;
}//for
return choice;
}//printMenu
function addCustomer(customers_par) {
//checks if an empty slot is available in the array passed in, and adds customer,
//else says array is full and returns nothing
//returns the changed array if a customer was added
var emptySlot = -1;
for(var i = 0; i < customers_par.length; i++) {
if(customers_par[i]["name"] == "XXXXXXX") {
emptySlot = i;
break;
}//if
}//for
if(emptySlot == -1) {
alert("Array is full");
return;
}
customers_par[emptySlot]["name"] = prompt("Enter Customer name");
customers_par[emptySlot]["address"] = prompt("Enter Customer address");
customers_par[emptySlot]["email"] = prompt("Enter Customer email");
return customers_par;
}//addCustomer
function main() {
//called when page is loaded and runs all the other functions
for(; ; ) {
var size = parseInt(prompt("How many Customers? Enter a positive number"));
if(!isNaN(size) && size > 0)
break;
}//for
var custs = initCustomers(size);
printCustomers(custs);
//printCustomers(initCustomers(size));
for(; ; ) {
var userChoice = printMenu();
if(userChoice == 1) {
custs = addCustomer(custs);
printCustomers(custs);
}//if choice is 1
if(userChoice == 2) {
alert("Thanks for using the customer app");
break;
}//if choice is 2
}//for
}//main
window.onload = function() {
main();
}//onload
</script>
</div>
<footer>
<p>
© Copyright by akhilesh-bajaj
</p>
</footer>
</div>
</body>
</html>
What is Poverty
: What is Poverty?Should developed nations provide relief for the poorest African nations? If yes, what form should that relief take? If not, why not? Be specific in your answer.
|
What is the optimal value of the objective function
: Consider the following linear programming problem: Use a graph to show each constraint and to identify feasible region. Identify the optimal solution point on your graph. What are the values of X and Y at the optimal solution? From your graph, what i..
|
Discuss the feasibility of each type of survey mode
: Discuss the feasibility of each type of survey mode for the case- Fabergé wants to test a new fragrance called "Lime Brut."
|
Importance of organizational culture and the implications
: Do some research on the topic of improving your leadership skills and then explain what you found interesting and describe specifically what you will do in the next month to enhance your leadership skills. Also, explain the importance of organizat..
|
Create a single page web application
: Create a single page web application that starts by initializing all eh customers. The page should present a menu that allows the user to view all customers, search for a customer based on name, phone or email, add a customer or delete a custome..
|
Agile development methods more practical
: What has changed in the software industry that may have rendered the "Waterfall" model obsolete? Or put another way, what has changed to render the "Agile" development methods more practical? But why have many I.T. departments resisted the adoption o..
|
What was happening that made the earlier style
: What was happening that made the earlier style acceptable for today's fashion. Did it correspond in some way to the current thinking of the clothing artist? Reflect current trends?
|
Are you adventurous
: Are you adventurous? Would you consider taking a passenger cruise on a cargo liner? Why or why not? What are the advantages and disadvantages as you see them?
|
Shipping transmission components
: You are a small company in the auto industry that is trying to get more business with Korean automakers in South Korea. You win a contract and will be shipping transmission components to Hyundai in South Korea on a regular basis. Obviously, you need ..
|