-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_csv3.html
40 lines (39 loc) · 1.26 KB
/
demo_csv3.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSV Textarea Only Example</title>
<p>This implementation should fallback to the innerHTML containing the textarea if JavaScript is disabled.</p>
<script type="module" src="csvtextarea.js" defer></script>
</head>
<body>
<form id="csv-form" action="/submit" method="POST">
<label for="groups">Enter Groups CSV Data:</label>
<csv-textarea
debug="true"
id="groups"
name="groups"
column-headings="group name, group id"
>
<textarea id="groups" name="groups" placeholder="Enter group name, comma and then clgid. One per line."></textarea>
</csv-textarea>
<p></p>
<button type="submit">Submit</button>
</form>
<script>
const csvForm = document.getElementById('csv-form');
csvForm.addEventListener('submit', function (event) {
event.preventDefault();
const csvComponent = document.getElementById('groups');
const csvData = csvComponent.toCSV();
const formData = new FormData();
formData.set('groups', csvData);
// Display the submitted form data.
for (const pair of formData.entries()) {
console.log(pair[0], pair[1]);
}
});
</script>
</body>
</html>