-
Notifications
You must be signed in to change notification settings - Fork 0
/
addTransaction.html
86 lines (81 loc) · 3.34 KB
/
addTransaction.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Transaction</title>
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h2 class="text-center mt-4">Add Transaction</h2>
<div class="row">
<div class="col-md-6 offset-md-3">
<form id="transactionForm">
<div class="form-group">
<label for="date">Date:</label>
<input type="date" class="form-control" id="date" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<input type="text" class="form-control" id="description">
</div>
<div class="form-group">
<label for="category">Category:</label>
<input type="text" class="form-control" id="category">
</div>
<div class="form-group">
<label for="cost">Cost:</label>
<input type="number" step="0.01" class="form-control" id="cost" required>
</div>
<div class="form-group">
<label for="currency">Currency:</label>
<input type="text" class="form-control" id="currency">
</div>
<div class="form-group">
<label for="email_address">Email Address:</label>
<input type="text" class="form-control" id="email_address" required>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
$('#transactionForm').submit(function(event) {
event.preventDefault();
var formData = {
Date: $('#date').val(),
Description: $('#description').val(),
Category: $('#category').val(),
Cost: $('#cost').val(),
Currency: $('#currency').val(),
customer_id: $('#email_address').val()
};
$.ajax({
type: 'POST',
url: 'http://localhost:5050/add_expense',
data: JSON.stringify(formData),
contentType: 'application/json',
success: function(response) {
console.log(response);
alert('Transaction added successfully!');
// Redirect or do something else upon successful submission
window.location.href = "welcomeAccount.html";
},
error: function(xhr, status, error) {
console.error(error);
alert('Failed to add transaction. Please try again.');
}
});
});
});
</script>
</body>
</html>