-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.html
More file actions
63 lines (53 loc) · 1.34 KB
/
create.html
File metadata and controls
63 lines (53 loc) · 1.34 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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>create test</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery.min.js"></script>
<script src="js/setup.js"></script>
<script>
$(document).ready(function() {
// when the enter key is pressed on any input
$('input[type="text"], input[type="number"]').on('keydown', function(e) {
if(e.keyCode == 13) {
$('.createBtn').click();
}
})
// when the create button is clicked
$('.createBtn').on('click', function() {
// send ajax request to create a new test
$('#ajaxStatus').html('Loading...');
$.ajax({
url: 'php/create_test.php',
data: {name: $('input[type=text][name=name]').val()},
success: function(response) {
if(response.indexOf('edit/?id=') == -1) {
$('#ajaxStatus').html(response);
return;
}
$('#ajaxStatus').html('');
window.location.href = response;
}
});
});
});
</script>
</head>
<body>
<!-- Page navigation -->
<div class='pageNav'>
<a href='./'>testing</a>
<a>create tests</a>
</div>
<!-- Contents -->
<h1>create test</h1>
<!-- Form -->
<table class='form'>
<tr><td>name</td><td><input type='text' name='name'/></td></tr>
</table>
<input type='button' value='next' class='createBtn'/>
<input type='button' value='cancel' class='backBtn'/>
<span id='ajaxStatus'></span>
</body>
</html>