diff --git a/case1/mpl_links_txt.html b/case1/mpl_links.html
similarity index 97%
rename from case1/mpl_links_txt.html
rename to case1/mpl_links.html
index 956d056..4e2cf02 100644
--- a/case1/mpl_links_txt.html
+++ b/case1/mpl_links.html
@@ -7,8 +7,8 @@
Case Problem 1
Monroe Public Library Government Links
- Author:
- Date:
+ Author: brett f
+ Date: 4-11-2019
Filename: mpl_links.html
-->
@@ -17,6 +17,8 @@
+
+
diff --git a/case1/mpl_links.js b/case1/mpl_links.js
new file mode 100644
index 0000000..47be58e
--- /dev/null
+++ b/case1/mpl_links.js
@@ -0,0 +1,23 @@
+"use strict";
+
+/*
+ New Perspectives on HTML5, CSS3, and JavaScript 6th Edition
+ Tutorial 13
+ Case Problem 1
+
+ Author: brett f.
+ Date: 4-11-2019
+
+ Filename: mpl_links.js
+
+*/
+
+window.addEventListener("load", function() {
+ var allSelect = document.querySelectorAll("form#govLinks select");
+
+ for (var i = 0; i < allSelect.length; i++) {
+ allSelect[i].onchange = function(e) {
+ location.href = e.target.value;
+ }
+ }
+});
diff --git a/case1/mpl_links_txt.js b/case1/mpl_links_txt.js
deleted file mode 100644
index fe21beb..0000000
--- a/case1/mpl_links_txt.js
+++ /dev/null
@@ -1,15 +0,0 @@
-"use strict";
-
-/*
- New Perspectives on HTML5, CSS3, and JavaScript 6th Edition
- Tutorial 13
- Case Problem 1
-
- Author:
- Date:
-
- Filename: mpl_links.js
-
-*/
-
-
diff --git a/case2/dl_expense_txt.html b/case2/dl_expense.html
similarity index 95%
rename from case2/dl_expense_txt.html
rename to case2/dl_expense.html
index 48fadef..c1caa98 100644
--- a/case2/dl_expense_txt.html
+++ b/case2/dl_expense.html
@@ -7,8 +7,8 @@
Case Problem 2
Travel Expense Report
- Author:
- Date:
+ Author: brett f.
+ Date: 4-11-2019
Filename: dl_expense.html
-->
@@ -70,20 +70,20 @@ Expense Report
First Name* |
M.I. |
Account* |
- |
+ |
|
|
|
Department* |
- |
+ |
| Social Security Number* |
|
Project* |
- |
+ |
diff --git a/case2/dl_expense.js b/case2/dl_expense.js
new file mode 100644
index 0000000..2ccb4ba
--- /dev/null
+++ b/case2/dl_expense.js
@@ -0,0 +1,98 @@
+"use strict";
+
+/*
+ New Perspectives on HTML5, CSS3, and JavaScript 6th Edition
+ Tutorial 13
+ Case Problem 2
+
+ Author: brett f.
+ Date: 4-11-2019
+
+ Filename: dl_expenses.js
+
+ Function List
+ =============
+
+ validateSummary()
+ Validates the data entry in the summary field.
+
+ calcClass(sumClass)
+ Sums up all of the data values for elements of the sumClass class.
+
+ calcExp()
+ Calculates the travel expenses from all categories and dates.
+
+ formatNumber(val, decimals)
+ Formats the value, "val" to the number of decimals indicated
+ by "decimals", adding thousands separators.
+
+ formatUSCurrency(val)
+ Formats the value, "val", as U.S. currency.
+
+*/
+
+
+window.addEventListener("load", function() {
+ var changingCells = document.querySelectorAll("table#travelExp input.sum");
+
+ for (var i = 0; i < changingCells.length; i++) {
+ changingCells[i].onchange = calcExp;
+ }
+
+ document.getElementById("submitButton").onclick = function() {
+ validateSummary();
+ };
+});
+
+function validateSummary() {
+ var summary = document.getElementById("summary");
+ if (summary.validity.valueMissing) {
+ summary.setCustomValidity("You must include a summary of the trip in your report.");
+ } else {
+ summary.setCustomValidity("");
+ }
+}
+
+function calcClass(sumClass) {
+ var sumFields = document.getElementsByClassName(sumClass);
+ var sumTotal = 0;
+
+ for (var i=0; i < sumFields.length; i++) {
+ var itemValue = parseFloat(sumFields[i].value);
+ if (!isNaN(itemValue)) {
+ sumTotal += itemValue;
+ }
+ }
+ return sumTotal;
+}
+
+
+function calcExp() {
+
+ var expTable = document.querySelectorAll("table#travelExp tbody tr");
+
+ for (var i = 0; i < expTable.length; i++) {
+ document.getElementById("subtotal"+i).value = formatNumber(calcClass("date"+i), 2);
+ }
+
+ document.getElementById("transTotal").value = formatNumber(calcClass("trans"), 2);
+ document.getElementById("lodgeTotal").value = formatNumber(calcClass("lodge"), 2);
+ document.getElementById("mealTotal").value = formatNumber(calcClass("meal"), 2);
+ document.getElementById("otherTotal").value = formatNumber(calcClass("other"), 2);
+ document.getElementById("expTotal").value = formatUSCurrency(calcClass("sum"));
+}
+
+
+
+
+
+
+
+function formatNumber(val, decimals) {
+ return val.toLocaleString(undefined, {minimumFractionDigits: decimals,
+ maximumFractionDigits: decimals});
+}
+
+function formatUSCurrency(val) {
+ return val.toLocaleString('en-US', {style: "currency", currency: "USD"} );
+}
diff --git a/case2/dl_expense_txt.js b/case2/dl_expense_txt.js
deleted file mode 100644
index bc32b41..0000000
--- a/case2/dl_expense_txt.js
+++ /dev/null
@@ -1,48 +0,0 @@
-"use strict";
-
-/*
- New Perspectives on HTML5, CSS3, and JavaScript 6th Edition
- Tutorial 13
- Case Problem 2
-
- Author:
- Date:
-
- Filename: dl_expenses.js
-
- Function List
- =============
-
- validateSummary()
- Validates the data entry in the summary field.
-
- calcClass(sumClass)
- Sums up all of the data values for elements of the sumClass class.
-
- calcExp()
- Calculates the travel expenses from all categories and dates.
-
- formatNumber(val, decimals)
- Formats the value, "val" to the number of decimals indicated
- by "decimals", adding thousands separators.
-
- formatUSCurrency(val)
- Formats the value, "val", as U.S. currency.
-
-*/
-
-
-
-
-
-
-
-
-function formatNumber(val, decimals) {
- return val.toLocaleString(undefined, {minimumFractionDigits: decimals,
- maximumFractionDigits: decimals});
-}
-
-function formatUSCurrency(val) {
- return val.toLocaleString('en-US', {style: "currency", currency: "USD"} );
-}
\ No newline at end of file
diff --git a/case3/mas_reg2_txt.html b/case3/mas_reg2.html
similarity index 96%
rename from case3/mas_reg2_txt.html
rename to case3/mas_reg2.html
index 63ca91a..59a8352 100644
--- a/case3/mas_reg2_txt.html
+++ b/case3/mas_reg2.html
@@ -7,8 +7,8 @@
Case Problem 3
Media Arts Society Registration Form #2
- Author:
- Date:
+ Author: brett f.
+ Date: 4-11-2019
Filename: mas_reg2.html
@@ -139,4 +139,4 @@ MAS22 Payment Form
-