forked from titat/project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform4.html
More file actions
193 lines (177 loc) · 5.73 KB
/
Copy pathform4.html
File metadata and controls
193 lines (177 loc) · 5.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="text.css">
<link href="carousel.css" rel="stylesheet">
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
h2{
border-bottom: 3px solid black;
color :black;
}
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
.t{
margin-top: 50px;
}
</style>
</head>
<title> Complex Form 4</title>
<div class="t jumbotron container">
<h2> Student Course</h2>
<br>
<form action="addtocourse.php" method="post" >
<title>Drop Down List</title>
<body>
<div>
<nav class="navbar navbar-inverse navbar-fixed-top " >
<div class="container">
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav ">
<li><a href="home.html">Home</a></li>
<li><a href="">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
</nav>
</div>
<div id="courselist"></div>
<br>
<p>Table</p>
<div id="POItablediv">
<table class = "table table-bordered" id="POITable" border="1">
<tr>
<td>Number</td>
<td>AppID</td>
<td>StudentID</td>
<td>Delete</td>
</tr>
<tr>
<td>1</td>
<td><input size=25 type="text" id="AppID" name = "AppID1" ></td>
<td><input size=25 type="text" id="StudentID" name = "StudentID1"></td>
<td><input type="button" id="delbutton" value="Delete" onclick="deleteRow(this)"/></td>
</tr>
</table>
<br>
<input size=10 type="hidden" id="maxrow" name = "i" value = "1" ><br>
<input type="button" id="addmorebutton" value="Add More Button" onclick="insRow()"/>
<br><br><input type="submit" value="Submit">
</div>
</form>
<form action = "upload_Form4.php" method="post" enctype="multipart/form-data">
<br><br><div id="courselist_csv"></div><br>
<input type="file" name="csv" id="fileToUpload">
<br>
<input type="submit" value="Add csv" name="submit">
</form>
</div>
</div>
<script>
document.getElementById("maxrow").value = 1;
var max_row;
function insRow()
{
document.getElementById("maxrow").innerHTML = len;
var x=document.getElementById('POITable');
// deep clone the targeted row
var new_row = x.rows[1].cloneNode(true);
// get the total number of rows
var len = x.rows.length;
// set the innerHTML of the first row
document.getElementById("maxrow").value = len;
new_row.cells[0].innerHTML = len;
// grab the input from the first cell and update its ID and value
var inp1 = new_row.cells[1].getElementsByTagName('input')[0];
inp1.id += len;
//inp1.name += len;
inp1.value = '';
// grab the input from the first cell and update its ID and value
var inp2 = new_row.cells[2].getElementsByTagName('input')[0];
inp2.id += len;
//inp2.name += len;
inp2.value = '';
// append the new row to the table
x.appendChild( new_row );
updateName();
}
function updateName(){
var table=document.getElementById('POITable');
var x=1;
var len = table.rows.length;
for (x=1;x<=len;x++){
var row = table.rows[x];
row.cells[0].innerHTML = x;
var inp1 = row.cells[1].getElementsByTagName('input')[0];
inp1.name = 'AppID'+ x;
var inp2 = row.cells[2].getElementsByTagName('input')[0];
inp2.name = 'StudentID'+x;
}
}
function deleteRow(row)
{
var i=row.parentNode.parentNode.rowIndex;
if(i!=1) document.getElementById('POITable').deleteRow(i);
updateName();
}
loadCourse();
//displayResponseTable();
function loadCourse(){
var xmlhttp = new XMLHttpRequest();
var url = "http://127.0.0.1/project/coursequery.php";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
displayResponseCourse(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
function displayResponseCourse(response) {
var i;
var out = "Course: <select id=\"Course\" name=\"Course\" class=\"required-entry\" onchange=\"javascript: displayResponseTable();\" ><option value=\"Select Course\">Select Course</option>";
var arr = JSON.parse(response);
for(i = 0; i < arr.length; i++) {
out += '<option value="'+arr[i].CourseID+'">'+arr[i].CourseName+' - '+arr[i].CourseDescription+'</option>';
}
out += "</select><\/script>";
document.getElementById("courselist").innerHTML = out;
document.getElementById("courselist_csv").innerHTML = out;
}
function displayResponseTable() {
var i;
var out = "<table id = \"myTable\">";
for(i = 0; i < 2; i++) {
out += "<tr><td>" +
"<input type = \"text\" name = \"AppID"+i+"\">"+
"</td><td>" +
"<input type = \"text\" name = \"StudentID"+i+"\">"+
"</td></tr>";
}
out += "</table>";
out += "<br><input type=\"submit\" value=\"Submit\">";
document.getElementById("table").innerHTML = out;
}
</script>
<br><br>
</form>
</body>
</html>