-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
50 lines (44 loc) · 1.54 KB
/
index.html
File metadata and controls
50 lines (44 loc) · 1.54 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
<!DOCTYPE html>
<html>
<head>
<title>User Data Entry</title>
</head>
<body>
<h1>User Data Entry</h1>
<form id="userDataForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br>
<label for="mobile">Mobile Number:</label>
<input type="text" id="mobile" name="mobile" required><br>
<input type="submit" value="Submit">
</form>
<script>
document.getElementById('userDataForm').addEventListener('submit', function(event) {
event.preventDefault();
const name = document.getElementById('name').value;
const mobile = document.getElementById('mobile').value;
const data = {
name: name,
mobile: mobile
};
const url = 'https://script.google.com/macros/s/AKfycbzqyUevkMyYJIi_Jz0dg02QV2XZeQhHZTdmrbmjvS6GhA4ZxTFqCO22xoEmekf0J8s/exec';
fetch(url, {
method: 'POST',
mode: 'no-cors',
cache: 'no-cache',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams(data).toString()
})
.then(response => {
console.log('Data recorded successfully!');
document.getElementById('userDataForm').reset();
})
.catch(error => {
console.error('Error recording data:', error);
});
});
</script>
</body>
</html>