|
|
Waterford West Hampton D_O_F_ Glasses |
WC-998-306-4094 |
Used |
Set of 4 glasses. |
$139.00 |
$119.00 |
alt="Product #539" /> |
________________________________________
Step 7. Create an interactive program to modify the table
Build an interactive program with JavaScript
1. You decide that you will automate creating the table header, footer, summary and caption.
2. On the body element, when the page loads, call a function named init.
3. In the init function, call the createHeader, createFooter, createCaption and addData functions. No parameters are passed.
4. In a JavaScript, create functions called init, createHeader, createFooter, createCaption andaddData.
Create the createFooter function
1. In the footer function display a footer row, that spans 9 columns and says "All saled are final."
2. The id for the row is set to prodFooterRow.
3. Set the footer row class name to productFoot.
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
1. In the function you will need the table and caption objects. You need to set the properties of the caption and append the caption to the table object.
2. The properties should set the text displayed to We have a broad range of products availableand a line break.
3. The font size is 14 pixels, and aligned to the top.
Create the createHeader function
1. In the createHeader function:
- Create the table object using getElementById
- Create the header row object using createElement.
- Append the header row to the table using appendChild.
- In the function, set the table properties.
- Set the border to 10 with background color lightslategray.
- Set the width to 960 pixels.
- Set the summary to: This product list shows what is available at our rummage sale!
- Set the class name to productHead.
- In the createHeader function, create the table head element.
- Set the table head element properties.
- Set the id and class to productHead.
- Append the head element to the table.
- Create the header row element using the tr tag, and
- Set any required properties.
- Set the id to prodHeaderRow
- Append the row to the head element.
- Create 1 array.
- The array called heading stores the 9 column heading names for each of the cells in the header row.
- Create a loop. Inside the loop:
- Create each header cell.
- Modify the class name of the cell
- Display the text.
- Add the cell to the header row object.
________________________________________
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
1. Create the table and body objects using getElementById.
- You already have a body table element in the table, so you don't need to append it to the table. We need to just add one row to the table body element.
- Create an array with 10 elements that has the text for each cell.
- The last element should be set to the product ID value (such as 1000).
- Note that the product ID is not in the actual table. We are just using that array element to store the ID value.
Create the row with the createElement function
1. Set the id of the row.
2. Set the class name to prodrow.
3. Append the row to the table body element. Do not add it to the table or the body, but the table body element. (If you are not sure what element that is, look it up!)
Create an array to change the cell contents and properties
1. Create an array.
2. Loop through the array. In the loop:
- Create the cells with createElement function.
- Set the cell properties to match your table properties and styles. (The properties you choose will vary based on your table.)
- Set the inner HTML value to the value in the array.
- If the cell is for the normal price set the class name to prodprice.
- If the cell is for the thumbnail set the class name to prodpics.
- Make sure in the HTML code, each cell in those columns has their class set to the same values. You can do this by hand or use the find and replace feature in your editor.
- Append the cell to the data row.
Problem 3
Your boss has asked you to create a web page that he can use to create invitations to the rummage sales! He wants to have different dates, text, colors and images in each invitation. You are going to use your programming skills and mix them with what you learn in this weeks lessons.
Learning Outcomes
- Demonstrate creativity and problem-solving skills.
- Create web pages and web programs that use: HTML5, cascading style sheets, dynamic HTML, JavaScript, forms with controls, and Canvas.
- Evaluate web pages and web programs to ensure that they use proper coding conventions and documentation.
________________________________________
Step 1. Create the overall HTML structure
1. Save your Word document in your homework folder. Add this to your web site in the homework folder after you have completed both problems.
2. Gather your data and create your basic page navigation structure.
3. Edit the week6-1.html page to have the same style sheet: homework.css * Note that problem 1 and 2 will use the same file!
4. Make sure you have links to all of the pages for this week and the home button in your main navigation menu. You should have a consistent style or theme for your web site that is unique. Don't copy off of other web sites!
5. Make sure there is some place on the home page that has links to all of the other pages. You can do this in the main menu if you chose the first page layout from week 2. If you chose the Jumbotron, just create a link to at least to the first page for each week.
6. For Problem 1, we'll work with week6-1.html.
________________________________________
Step 2. Create an interactive program with HTML, CSS, JavaScript and DOM
This part of the activity, you will create the form using JavaScript and the DOM. goal is to meet the program requirements above, demonstrate your understanding of the DOM and write efficient code that works. As part of this assignment you will change the styles dynamically in JavaScript, create elements and append the styles and elements to other elements in the page.
Program Requirements:
Build an interactive program with JavaScript. Remember that your form should be different, showing your creativity. *Note that there are many different ways to solve this problem. The TIPS at the end of the Problem 1 directions should help you when you are troubleshooting your homework!I've given some direction. It's up to you to be creative.
Create the web page structure
Create a main div element and assign it a class called main. Inside the div element insert an aside with the id, leftaside and a div with the id placeholder. The left side will be the form you will build. Format the layout of the main, leftaside and placeholder. The leftaside should be about one third of the window. Let's start in Problem 1 with just the form.
Create the form elements
1. You will need labels for each of the form fields and will want to set the width property, and set the inline attribute to inline-block. You will need to come up with your own naming conventions for your form fields! We are at that point in the coure where you should be able to do this.
2. Use different form field types. The minimum types include textbox, textarea, color, date, dropdown list, radiobutton or checkbox, and a submit button.
3. The values of at least one of the dropdown lists should be dynamically generated. You need to incorporate images in some dynamic way as well. To get the image to be next to a radio button or checkbox list, use the display property and set it to inline as well.
4. In the submit button call the function that will apply the styles.
Create the functions
*Note that there are many different ways to solve this problem. However, it's up to you to follow the DOM and verify the syntax with the standards and your readings!
1. Create the three functions, populateStyles, populateFonts and populateImages. Again you can rename them to be appropriate to your program!
2. Each form element that ‘binds' to some data structure should have it's own function. In the example, there is one function for populating the border styles in the dropdown list, one for the fonts, and one for the radiobutton and images. Your program may be different.
In each function populate the form field using JavaScript
1. For example, in the populateStyles function you might:
- Create a string variable, which contains a semi-colon separated list of the values of the border styles attribute. You can look them up on the W3Schools site.
- Create a variable for the array.
- Split the string with the border styles using the semi-colon as the delimiter, and pass it to the variable you created.
- Rotate through the array.
- Retrieve the style for each element (i).
- Create an option element and set the name, value and text properties using the border style name from the array.
- Append the option element to the form dropdown list or radiobutton list elements in your form.
- You could do something similar to bind a list of font names to a dropdown list. The key is you are creating ‘option' tags/elements to the parent element which may be a select tag, input tag, etc.
Display the forms
Note: This is just a few suggestions. How you choose to create the form dynamically is up to you to design.
1. Combining elements can be tricky. In the example, I combined the input tag for the radio button and the images.
2. For each element in the list, you need to create both, an input element and an image element, set the properties of each and append them to the parent element. In this example, there are two images in a row. You can customize this. You can use the modulus operator to determine if the element is an even or odd element and append a line break object as needed.
3. The key is depending on your properties the image source will need to have a path concatenated with the image name. You can customize the id, name, value, class name and other attributes. Again, the best way to do this is to create what you want as your output, as an example, and then, go back and replace the static text with your variables.
Customize the styles
17. Don't forget to modify the style properties of the elements dynamically! The evalution of your program will include how the output appears in the browser. You can make modifications in the JavaScript program and/or use CSS and modify the style rules for the HTML element(s) that display the results
________________________________________
Step 3. Review and document your HTML, CSS and JavaScript programs
Review and document your program
1. Review your program to make sure you also used descriptive names for the variables, classes and other elements and stuctures.
2. Preview and test your program. Again, make sure there is adequate documentation in the CSS, HTML and JavaScript programs!
3. If you need additional screen shots to show your program, just add them here.
4. Screen shots go here. Show the web page in the browser with the values displayed!
5. Screen shots go here. Show the HTML, CSS code and Javascript
________________________________________
TIP: Choosing to work with Objects or InnerHTML
You have many choices on how to program. You can assemble the innerHTML using a string, as shown. However this can be messy with multiple quotation marks. If you use this method, it helps to have the ‘output' of what code you want to write first, and reverse engineer and put in the variables. This can be very tricky with the single and double nested quotes and where you append values to variables. Most students have done this kind of thing in their first programming course.
// retrieve the style attribute from a data structure like and array or string.
var name = borderStyles[i];
myResults += '';
}
// After creating all of the
Note that above only partial snippets are shown to give you an idea. It's up to you to write your own program! Do you see the difference? Mixing and matching can be very difficult, so choose wisely!
TIP: Retrieving colors and populating a dropdown list.
This is to show you that you ‘can' create your own list of colors and populate the list. However, the support for background color for the individual options varies with browsers Furthermore this is only the 16 named colors. There are 140 named colors supported. With 32-bit colors you can have millions of colors. A color picker is much more useful if you want the range of options and much easier to work with. However, we still use this basic technique when we don't have that option.
function populateColors(){
var myResults ="";
var namedColors ="Aqua=#00FFFF;Black=#000000;Blue=#0000FF;Fuchsia=#FF00FF;"
+ "Gray=#808080;Green=#008000;Lime=#00FF00;Maroon=#800000;Navy=#000080;"
+ "Olive=#808000;Purple=#800080;Red=#FF0000;Silver=#C0C0C0;Teal=#008080;"
+ "White=#FFFFFF;Yellow=#FFFF00";
var colorArray = namedColors.split(";"); // put into an array
for(var i = 0; i < colorArray.length; i++){
var name = colorArray[i].split('=')[0];
var value = colorArray[i].split('=')[1];
myResults += '";
}
var bc = document.getElementById("backgroundColor");
bc.innerHTML = myResults;
}
________________________________________
________________________________________
Problem 4:
Step 1. Create the overall HTML structure
You will work with the same form and process the form. As you can see, the challenge is to create the unique content based on the values in the form.
Create the function
1. Make a new copy of your pagefor backup purposes. You will work on week6-1.html.
2. Your task is to process the form. Create the function to apply the styles.
3. The first task is to set the innerHTML property for the parent object (the placeholder) to an empty string so you reset the form field.
________________________________________
Step 2. Create an interactive program with JavaScript, CSS and DOM
Configure the styles and properties with JavaScript
1. Since the only element in the form to show the results is the placeholder, you'll need to create elements to show the data, and then modify the styles of those elements using the values from the form. In the example below you can see how to assign static values or dynamic from other form elements. You will want to append the element to the parent element.
var ph = document.getElementById("placeholder");
ph.style.fSize = "18px";
ph.style.fFamily = document.getElementById("tfFam").value;
2. You will need to format the date using the date object and format the value as a local string, using toLocaleDateString();
3. For some elements such as the dropdown list, radiobutton or checkbox lists, you need to iterate through each element to determine if the element was selected before you can assign the value to your variable.
Problem 5:
Step 1. Analyze web programs in order to test, debug, and improve them
Provide your own original example for each of the explanations you provide.
1. Visit https://www.w3schools.com/js/js_htmldom_events.asp (Links to an external site.). Explain how to add event attributes to HTML elements, and assign functions to the attributes. Explain how to assign a function in JavaScript using the HTML DOM. Provide your own original examples.
2. Visit https://www.w3schools.com/js/js_htmldom_eventlistener.asp (Links to an external site.). Explain how to add and remove an event listenter to an element dynamically in JavaScript. Compare the difference between event bubbling and event capturing. Provide your own original examples.
3. Visit https://www.w3schools.com/js/js_htmldom_navigation.asp (Links to an external site.). Explain how content is added to elements such as div tags, and how nodes are added inside other nodes. What is the root element? Explain the difference between siblings and parent nodes. Provide your own original examples.
4. Visit https://www.w3schools.com/js/js_htmldom_nodes.asp (Links to an external site.). How do you create nodes on the fly and add them to your page using JavaScript? Provide your own original examples.
5. Visit https://www.w3schools.com/js/js_htmldom_methods.asp (Links to an external site.). How would you retrieve a value from a form field and then display it in the web page? Provide your own original examples.
https://www.dropbox.com/s/86e7skp24qnnx2l/web-programming.zip?dl=0
Request for Solution File
1431568
Questions
Answered
Start Excelling in your courses, Ask a tutor for help and get answers for your problems !!
ask Question