-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspinitron-autofill.js
40 lines (34 loc) · 1.41 KB
/
spinitron-autofill.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
data = {YOUR DATA HERE}
const tbody = document.querySelector('.personas tbody');
data.forEach((person, index) => {
const row = document.createElement('tr');
// Add `email`
const emailInput = document.createElement('input');
emailInput.type = 'email';
emailInput.id = `personacreateform-${index}-email`;
emailInput.name = `PersonaCreateForm[${index}][email]`;
emailInput.value = person.email;
const emailCell = document.createElement('td');
emailCell.appendChild(emailInput);
row.appendChild(emailCell);
// Add `name`
const nameInput = document.createElement('input');
nameInput.type = 'text';
nameInput.id = `personacreateform-${index}-name`;
nameInput.name = `PersonaCreateForm[${index}][name]`;
nameInput.value = person.name;
const nameCell = document.createElement('td');
nameCell.appendChild(nameInput);
row.appendChild(nameCell);
// Add `djName`
const djNameInput = document.createElement('input');
djNameInput.type = 'text';
djNameInput.id = `personacreateform-${index}-djname`;
djNameInput.name = `PersonaCreateForm[${index}][djName]`;
djNameInput.value = person.djName;
const djNameCell = document.createElement('td');
djNameCell.appendChild(djNameInput);
row.appendChild(djNameCell);
// Append the row to the table body
tbody.appendChild(row);
});