File tree Expand file tree Collapse file tree 3 files changed +142
-0
lines changed
Charles/Week5/ed_week5/tiffanyweek5 Expand file tree Collapse file tree 3 files changed +142
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+
3+ < html lang ="en ">
4+
5+ < head >
6+
7+ < meta charset ="UTF-8 ">
8+
9+ < title > Construction Pricing</ title >
10+
11+ < link rel ="stylesheet " href ="red_test.css "/>
12+
13+ </ head >
14+
15+ < body >
16+
17+ < main >
18+
19+ < h1 > Materials for Sale</ h1 >
20+
21+
22+
23+ < table width ="100% ">
24+
25+ < thead >
26+
27+ < tr >
28+
29+ < th > Material</ th >
30+
31+ < th > Price</ th >
32+
33+ < th > In Stock</ th >
34+
35+ </ tr >
36+
37+ </ thead >
38+
39+ < tbody id ="inventory ">
40+
41+ < tr >
42+
43+ < td > Wood</ td >
44+
45+ < td > $15</ td >
46+
47+ < td id ="woodStock " class ="true "> Yes</ td >
48+
49+ </ tr >
50+
51+ </ tbody >
52+ < tfoot >
53+ < tr >
54+ < td > < input type ="text " id ="name " /> </ td >
55+ < td > < input type ="number " id ="price " /> </ td >
56+ < td > < input type ="checkbox " id ="in_stock " /> </ td >
57+ </ tr >
58+ </ tfoot >
59+ </ table >
60+
61+
62+ < button id ="add_item "> Add Item</ button >
63+ < button > Add Stock</ button >
64+
65+ < button > Remove Stock</ button >
66+
67+
68+
69+ </ main >
70+
71+
72+ < script src ="pricing_raw.js "> </ script >
73+ </ body >
74+
75+ </ html >
Original file line number Diff line number Diff line change 1+ /* we are going to need:
2+ - list that stores our inventory
3+ -material, price, in-stock
4+ - function that adds to the list from a form
5+ - function that can remove from the list
6+
7+ */
8+ window . onload = function ( ) {
9+ document . getElementById ( "add_item" ) . onclick = addinventoryitem ;
10+ } ;
11+
12+
13+ var inventory = [ ] ;
14+ // constructor function for an inventory item
15+
16+ // dont add the () after function for event listenr
17+ function makeinventoryitem ( name , price , in_stock ) {
18+ this . name = name ;
19+ this . price = price ;
20+ this . in_stock = in_stock ;
21+ }
22+
23+
24+
25+ //add inventory item to list
26+ function addinventoryitem ( ) {
27+ var name = document . getElementById ( "name" ) . value ;
28+ var price = document . getElementById ( "price" ) . value ;
29+ var in_stock = document . getElementById ( "price" ) . value ;
30+
31+ var generic = new makeinventoryitem ( name , price , in_stock ) ;
32+
33+
34+ inventory . push ( generic ) ;
35+ console . log ( inventory ) ;
36+
37+ // create new inventory item object
38+
39+ // add new object to the inventory array
40+
41+ //update inventory displayed on web page
42+ }
Original file line number Diff line number Diff line change 1+ body {
2+ width : 50% ;
3+ margin : 0 auto;
4+ padding : 20px ;
5+ text-align : center;
6+ }
7+
8+ main {
9+ border : solid 1px # 333 ;
10+ }
11+
12+ h1 {
13+ background-color : # F59581 ;
14+ padding : 35px ;
15+ margin : 0 auto auto;
16+ }
17+
18+ .false {
19+ background-color : # c00 ;
20+ color : # fff ;
21+ }
22+
23+ .true {
24+ background-color : # 0c0 ;
25+ }
You can’t perform that action at this time.
0 commit comments