showing results for - "javascript steps"
Allison
20 Sep 2016
1// 2-now want to craet another table to but the data in it 
2
3//but before we creat it we need a constructor function 
4
5function data(from, to, capacity, reserve,lefted) {
6this.from=from;
7this.to=to;
8this.capacity=capacity ;
9this.reserve=reserve ;
10this.lefted=0;
11this.leftedSum=0
12
13}
14
15
16//now we can creat the table 
17data.prototype.render=function()//Acsses the constructor function
18{
19 var tableEl = document.getElementById("table");
20
21var trEl1=document.createElement('tr');
22tableEl.appendChild(trEl1);
23
24var tdEl1 = document.createElement('td');
25trEl1.appendChild(tdEl1);
26tdEl1.textContent=`${this.from}`
27
28
29var tdEl2 = document.createElement('td');
30trEl1.appendChild(tdEl2);
31tdEl2.textContent=`${this.to}`
32
33
34
35var tdEl3 = document.createElement('td');
36trEl1.appendChild(tdEl3);
37tdEl3.textContent=`${this.capacity}`
38
39
40
41var tdEl4 = document.createElement('td');
42trEl1.appendChild(tdEl4);
43tdEl4.textContent=`${this.reserve}`
44
45
46var tdEl5 = document.createElement('td');
47trEl1.appendChild(tdEl5);
48tdEl5.textContent=`${this.lefted}`
49
50}
51
52//call the function 
53data.prototype.render();
54
55
Christopher
27 Nov 2017
1//define the html form in JS
2var formEl = document.getElementById("form");
3var allData=[];
4
Monika
18 May 2016
1//want to link the form inputs with the submit 
2
3// add event listner 
4
5formEl.addEventListener("submit",click);
6
7function click(event){
8    event.preventDefault();
9 var from = event.target.from.value;
10 var to = event.target.to.value;
11 var capacity = event.target.capacity.value;
12 var reserve = event.target.reserve.value;
13 var object=new data(from,to,capacity,reserve);
14 object.leftedSeats();
15 object.render();
16 object.total();
17 set();
18
19}
20
21