forked from sn82978/VenusHacks2024Final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit_location.html
72 lines (64 loc) · 1.9 KB
/
submit_location.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Increment Column in Database</title>
<style>
.message {
font-size: 1.5em;
color: green;
display: none;
}
</style>
</head>
<body>
<h1>Database Update Example</h1>
<select id="columnSelect">
<option value="column1">Column 1</option>
<option value="column2">Column 2</option>
<option value="column3">Column 3</option>
</select>
<p id="message" class="message">Submission Successful</p>
<script>
// Function to handle the AJAX request
function incrementColumn(columnName) {
document.getElementById('message').style.display = 'block';
fetch('incrementColumn.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'incrementColumn',
columnName: columnName
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('message').textContent = 'Column Incremented Successfully';
} else {
document.getElementById('message').textContent = 'Error';
document.getElementById('message').style.color = 'red';
}
})
.catch(error => {
console.error('Error:', error);
document.getElementById('message').textContent = 'Error';
document.getElementById('message').style.color = 'red';
});
}
// Event listener for the dropdown menu
document.getElementById('columnSelect').addEventListener('change', function() {
const selectedColumn = this.value;
incrementColumn(selectedColumn);
});
// Automatically trigger increment on page load (optional)
window.onload = function() {
const selectedColumn = document.getElementById('columnSelect').value;
incrementColumn(selectedColumn);
};
</script>
</body>
</html>