-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode2.js
More file actions
56 lines (42 loc) · 1.83 KB
/
Copy pathcode2.js
File metadata and controls
56 lines (42 loc) · 1.83 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
//main setting page operation
document.getElementById('DebtPayoffPlan').addEventListener('click', function(event) {
window.location.href = "DebtPayoffPlan.html";
});
document.getElementById('FinancialGoal').addEventListener('click', function(event) {
window.location.href = "financialGoal.html";
});
document.getElementById('home').addEventListener('click', function(event) {
window.location.href = "home.html";
});
document.getElementById('ExportTransactionHistory').addEventListener('click', function(event) {
window.location.href = "ExportTransactionHistory.html";
});
document.getElementById('Security').addEventListener('click', function(event) {
window.location.href = "security.html";
});
//
//bottom click operation
document.getElementById('addNewGoal').addEventListener('click', function(event) {
window.location.href = "addGoal.html";
});
document.getElementById('goal-form').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent default form submission
const goalsName = document.getElementById('goalsName').value;
const totalAmount = document.getElementById('totalAmount').value;
const currentBudget = document.getElementById('currentBudget').value;
if (goalsName.trim() !== '' && totalAmount.trim() !== '' && currentBudget.trim() !== '') {
fetch('updateBudge.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ goalsName, totalAmount, currentBudget })
})
.then(response => response.json())
.then(data => {
alert(data.message);
window.location.href = "financialGoal.html"; // Redirect on success
})
.catch(error => console.error('Error:', error));
} else {
alert('Please enter all the fields.');
}
});