-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
145 lines (103 loc) · 3.55 KB
/
index.html
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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<script>
$(document).ready(function(){
$("#action-container").hide();
$("#title-link").on('click',function(){
alert("Alert");
});
setInterval(function(){
updateCars();
},1000);
function updateCars(){
$.ajax({
url: 'display_cars.php',
type: 'POST',
success:function(show_cars){
if(!show_cars.error){
$('#show-cars').html(show_cars);
}
}
});
}
$('#search').keyup(function(){
var search = $('#search').val();
$.ajax({
url:'search.php',
data:{search:search},
type: 'POST',
success:function(data){
if(!data.error){
$('#result').html(data);
}
}
});
});
//add cars to db
$("#add-car-form").submit(function(event){
event.preventDefault();
//take all data from form
var postData = $(this).serialize();
var url = $(this).attr('action');
$.post(url,postData, function(php_table_data){
$("#car-result").html(php_table_data);
$("#add-car-form")[0].reset();
});
});//Add car code
});//document ready
</script>
<div id="container" class="col-xs-6 col-xs-offset-3">
<h1>Search Our Database</h1>
<div class="mb-3">
<input class="form-control" type="text" name="search" id="search" placeholder="Search our inventory">
</div>
<br>
<br>
<h2 class="bg-success" id="result"></h2>
<div class="row">
<form id="add-car-form" class="col-x-6" method="POST" action="add_cars.php">
<div class="form-group">
<input type="text" name="car_name" class="form-control" required>
</div>
<br>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Add car">
<input type="reset" class="btn btn-secondary" value="Clear">
</div>
</form>
<div class="col-xs-6">
<p id="feedback" class="bg-success"></p>
<div id="action-container">
</div>
</div>
<div class="row">
<div class="col-xs-6">
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
</tr>
</thead>
<tbody id="show-cars">
</tbody>
</table>
</div>
</div>
<div class="col-xs-6">
<div id="car-result"></div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
</body>
</html>