Using the project structure you created for Assignment 1, create a new HTML5 web
ID: 3675616 • Letter: U
Question
Using the project structure you created for Assignment 1, create a new HTML5 web page and name it Exam1.html.
Create a style sheet file and name it Exam1.css, and save it in the styles folder. Add a link to this file from your web page.
Create a web page that allows a user to input:
An item Name
An item description
An item price
A minimum discount amount (%)
A maximum discount amount (%)
Whether the sale is:
Local – Add 5% Sales tax
Web Order – No Sales tax
Calculate the:
Item Discount amounts for the minimum through maximum discounts in 1% increments
The discounted item price for the minimum through maximum discounts in 1% increments
The item price with the applicable sales tax for the minimum through the maximum discounts in 1% increments (Sales tax should be applied to the discounted item price.)
Display:
The item name and description
In table form:
Discount %
Item discount amount
Discounted item price
Item price with tax
Format input and output with appropriate labels and headings.
Using a style sheet, format the web page so that the input and output areas are clearly defined and the contents are neatly organized.
Upon completion, submit your work by saving the project and folder structure in a Zip file and submit the Zip file through the assignment submission link.
Link to student home page
Create a Header & Footer and place a:
Page title in header (Use the Assignment Name as the title)
Student name & email in footer
Add a link to this assignment in your home page
This is what I have so far:
<!DOCTYPE html>
<html>
<head>
<title>Chaz Thornton IS 491 Exam 1</title>
<link rel="stylesheet" type="text/css" href="styles/Exam1.css"/>
<script src="js/Exam1.js"></script>
</head>
<body>
<div id="myform">
<body>
<h1>Exam 1</h1>
<hr>
<label>Item Name:</label>
<input type="text" id="itemName">
<br><br>
<label>Item Description:</label>
<input type="text" id="itemDescription">
<br><br>
<label>Item Price:</label>
<input type="number" id="itemPrice">
<br><br>
<label>Minimum Discount Amount (%):</label>
<input type="number" id="minDiscount">
<br><br>
<label>Maximum Discount Amount (%):</label>
<input type="number" id="maxDiscount">
<br><br>
<label>Order Type:</label>
<input type="radio" value= "Local" id="Local">Local
<input type="radio" value= "WebOrder" id="WebOrder">Web Order
<br><br>
<br>
<hr>
<button id="button">Show Item Information:</button>
<br><br>
<label id="itemNameDisplay">Item Name:</label>
<br>
<br>
<label id="itemDescriptionDisplay">Item Description:</label>
<br>
<br>
<button id="calculate">Display Results:</button>
<br><br>
<hr>
<br>
<div id="myDiscountTable">
</div>
</body>
<footer>Chaz Thornton
<br>
<br>
cnt3@uab.edu</footer>
</html>
JavaScript:
function ItemInfo()
{
var name = document.getElementById("itemName").value;
var displayName = document.getElementById("itemNameDisplay");
displayName.innerHTML = "Item Name: " + name;
var description = document.getElementById("itemDescription").value;
var displayDescription = document.getElementById("itemDescriptionDisplay");
displayDescription.innerHTML = "Item Description: " + description;
}
function DisplayDiscount()
{
var itemPrice = document.getElementById("itemPrice").value;
var minDiscount = document.getElementById("minDiscount").value;
var maxDiscount = document.getElementById("maxDiscount").value;
var taxAmt = 1;
var Local = document.getElementById("Local");
var WebOrder = document.getElementById("WebOrder");
If (Local.checked)
{
taxAmt = 0.05;
}
}
function addRow()
{
var itemPrice = document.getElementById("itemPrice").value;
var minDiscount = document.getElementById("minDiscount").value;
var maxDiscount = document.getElementById("maxDiscount").value;
var taxAmt = 1;
var Local = document.getElementById("Local");
var WebOrder = document.getElementById("WebOrder");
If (Local.checked)
{
taxAmt = 0.05;
}
var newDisplay=new Array(4);
var rowCount;
var row;
var itemDiscount = 0;
var itemDiscountPrice = 0;
var itemPricewithTax = 0;
var rows = new Array();
for (var k=minDiscount; k<= maxDiscount; k++)
{
var newRow = new Array();
itemDiscount = itemPrice * k * 0.01;;
itemDiscountPrice = itemPrice - itemDiscount;
itemPricewithTax = itemDiscountPrice * taxAmt;
newRow.push(k);
newRow.push(itemdiscount);
newRow.push(itemDiscountPrice);
newRow.push(itemPricewithTax);
rows.push(newRow);
}
var myTab = document.createElement("TABLE");
myTab.border = "2";
var nC = 4;
var row = myTab.insertRow(-1);
var h1 = document.createElement("TH");
h1.innerHTML = "Discount %";
row.appendChild(h1);
var h2 = document.createElement("TH");
h2.innerHTML = "Discount Amount %";
row.appendChild(h2);
var h3 = document.createElement("TH");
h3.innerHTML = "item price with discount %";
row.appendChild(h3);
var h4 = document.createElement("TH");
h4.innerHTML = "item price with tax %";
row.appendChild(h4);
for (var k=0; k < rows.length; k++)
{
row = table.insertRow(-1);
for (var k2 = 0; k2 < rows[0].length; k2++)
{
var newCell = row.insertCell(-1);
newCell.innerHTML = rows[k][k2];
}
}
var myDiscountTable = document.getElementById("myDiscountTable");
myDiscountTable.innerHTML = "";
myDiscountTable.appendChild(myTab);
}
I cannot get the table to display. Can someone please help
Explanation / Answer
<table border="1|0">
var myTab = document.createElement("TABLE");
myTab.border = "2";
var nC = 4;
var row = myTab.insertRow(-1);
var h1 = document.createElement("TH");
h1.innerHTML = "Discount %";
row.appendChild(h1);
var h2 = document.createElement("TH");
h2.innerHTML = "Discount Amount %";
row.appendChild(h2);
var h3 = document.createElement("TH");
h3.innerHTML = "item price with discount %";
row.appendChild(h3);
var h4 = document.createElement("TH");
h4.innerHTML = "item price with tax %";
row.appendChild(h4);
for (var k=0; k < rows.length; k++)
{
row = table.insertRow(-1);
for (var k2 = 0; k2 < rows[0].length; k2++)
{
var newCell = row.insertCell(-1);
newCell.innerHTML = rows[k][k2];
}
}
var myDiscountTable = document.getElementById("myDiscountTable");
myDiscountTable.innerHTML = "";
myDiscountTable.appendChild(myTab);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.