The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 3 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
View the cookies
View the web page and fill out the questions. In your browser, the way to access cookies will vary. For Mozilla Firefox, go to your Preferences menu. (On a Mac the link is in the Firefox menu) Then select Properties. Click on Privacy in the menu. Then click the Show Cookies button. Enter the name of one of your cookies. You can see the cookie name, content (value), host, path and expires properties.
Problem 2:
As usual, this second problem is more challenging than the first, and will test your creativity and application of programming to web development. Your boss has asked you to create a page that displays a table with of 5 products. He liked your week3-1.html page and said you could use that page as a way to display the products. But he wants to build in some way to modify the table structure on the fly, and modify the data in the table dynamically. You will not create the shopping cart at this time.
Review:
This activity will require you to create objects dynamically as well as modify the styles using CSS and JavaScript. Review how to do this first, before starting this assignment.
TIPS: Using styles to style table elements
It’s useful to use the class and id selectors in the style sheet. This also applies to the header row, cells, and footer. You should feel comfortable working with CSS by now.
TIPS: Using JavaScript to style table elements and set the properties of elements
You can set any property using:
objectname.property = “new value”;
While this method works, and will override other settings, bgColor isn't a valid HTML attribute! However some browsers may still allow this.
oTHead.bgColor = "#A94442";
A better method is to use style. This is one of the methods in your text. Again, you could try to use bgColor, but it’s not the best because the bgColor property is not the current term.
oTHead.style.bgColor = "#A94442";
A better method is to use the combination of style and proper name, backgroundColor.
oTHead.style.backgroundColor = "#A94442";
Cascading style rules can get very tricky when setting them inline and with CSS and JavaScript. Setting some attributes this way may not overwrite an inline style attribute.
Add an attribute to the HTML element
This way will work but remember that this just adds the attribute to the HTML element. It doesn’t validate the attribute name or value. So be careful with your code. Always look at the html generated and validate it with the validation tools you learned about earlier. You can add any attribute this way, not just style.
oTHead.setAttribute("style", "background-color: #A94442;");
When you create elements dynamically, you can also set the attributes dynamically before or after you append the element to it’s parent.
oRow = document.createElement("tr");
oRow.id = "TEST ROW";
oTBody.appendChild(oRow);
This process is the same, for each element you create. Create the element by passing the actual tag to the createElement method. Then you append the element to it’s parent element using appendChild.
oCell = document.createElement("td");
oRow.appendChild(oCell);
// You can also set the content inside the elements using innerHTML.
oCell.colSpan = "9";
oCell.innerHTML = "TEST ROW";
// You can also set the class using className.
oCell.classnName = "myCell";
Step 5. Create the overall structure for the page
Step 6. Modify the structure for the tableModify the table structure in HTML
You need to make some changes to your table.
Your boss said that he would like you to insert two columns on the left side of the table.
Make sure your table ID is hard coded to productTable.
The body should be set to productBody.
Each row, the id is set to row1000, where the word row is appended to the ID. The class for each row needs to be set to prodrow.
Use the code below as a guide to set up your HTML table.
Remember to customize your table
<table id="productTable">
<tbody id="productBody">
<tr id="row539" class="prodrow">
<td><input type="image" src="../images/btnbuy.gif"></td>
<td><input type="image" src="../images/btnlike1.gif"></td>
<td><a href="product.html?productid=539">Waterford West
Hampton D_O_F_ Glasses</a></td>
<td>WC-998-306-4094</td>
<td>Used</td>
<td>Set of 4 glasses.</td>
<td class="prodprice">$139.00</td>
<td>$119.00</td>
<td class="prodpics"><a href="../images/products/539.jpg" target="_blank">
<img class="prodthumb" src="../images/thumbnails/539.gif"
alt="Product #539" /></a></td>
</tr>
Step 7. Create an interactive program to modify the tableBuild an interactive program with JavaScript
Create the createFooter function
Reminder: You will need to create the table and footer objects, set the properties for the row, create the cell, append the cell to the row, and then set the cell properties.
Create the createCaption function
Create the createHeader function
Append the header row to the table using appendChild.
In the function, set the table properties.
In the createHeader function, create the table head element.
Create the header row element using the tr tag, and
Create 1 array.
Create a loop. Inside the loop:
Step 8. Create an interactive program to insert data into a table
Create an interactive program using JavaScript and insert data into the table element.
Create the addData function
Create an array with 10 elements that has the text for each cell.
Create the row with the createElement function
Create an array to change the cell contents and properties
Step 9. DocumentationReview and document your programs
Document your program. * This means all HTML, CSS and JavaScript programs!
Use proper nesting and indentation for all code
User proper naming conventions for the IDs and names of elements, names of classes used in all code
Include comments in the all code files (name, date, purpose of code, functions, variables)
Save this file as Homework5_LastName.docx. Add this to your web site in the homework folder after you have completed both problems
Include a screen shot of both web pages in the browser showing that your programs ‘worked’.
Include a screen shot of all of our code, showing your indentation and nesting of the elements.
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly