-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
82 lines (72 loc) · 2.98 KB
/
app.js
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
// app.js
import { initializeApp } from 'firebase/app';
import { getDatabase, ref, push } from 'firebase/database';
const firebaseConfig = {
apiKey: "AIzaSyB821BKA-ewVHTtfNU4ru1395OXh8tRCz8",
authDomain: "medq-31478.firebaseapp.com",
databaseURL: "https://medq-31478-default-rtdb.asia-southeast1.firebasedatabase.app",
projectId: "medq-31478",
storageBucket: "medq-31478.appspot.com",
messagingSenderId: "728089087143",
appId: "1:728089087143:web:1b392cc793d2276e6cdf82",
measurementId: "G-CYDBRTC0QM"
};
const app = initializeApp(firebaseConfig);
const database = getDatabase(app);
// function submitForm() {
// console.log('Submit button clicked.');
// const name = document.getElementById('name').value;
// const age = document.getElementById('age').value;
// const sex = document.getElementById('sex').value;
// const aadhar = document.getElementById('aadhar').value;
// const address = document.getElementById('address').value;
// const department = document.getElementById('department').value;
// console.log('Form values:', name, age, sex, aadhar, address, department);
// // Push data to Firebase
// database.ref('appointments').push({
// name: name,
// age: age,
// sex: sex,
// aadhar: aadhar,
// address: address,
// department: department
// }).then(() => {
// alert('Appointment booked successfully!');
// // You can redirect to another page if needed
// // window.location.href = 'success.html';
// }).catch(error => {
// console.error('Error booking appointment:', error);
// alert('Error booking appointment. Please try again.');
// });
// }
function submitForm() {
try {
console.log('Submit button clicked.');
const name = document.getElementById('name').value;
const age = document.getElementById('age').value;
const sex = document.getElementById('sex').value;
const aadhar = document.getElementById('aadhar').value;
const address = document.getElementById('address').value;
const department = document.getElementById('department').value;
console.log('Form values:', name, age, sex, aadhar, address, department);
// Push data to Firebase
database.ref('appointments').push({
name: name,
age: age,
sex: sex,
aadhar: aadhar,
address: address,
department: department
}).then(() => {
alert('Appointment booked successfully!');
// You can redirect to another page if needed
// window.location.href = 'success.html';
}).catch(error => {
console.error('Error booking appointment:', error);
alert('Error booking appointment. Please try again.');
});
} catch (error) {
console.error('Error in submitForm:', error);
alert('An unexpected error occurred. Please check the console for details.');
}
}