-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-form.js
40 lines (33 loc) · 1.16 KB
/
create-form.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
<script type="text/javascript">
function postForm() {
const SCHOOLID = '0000';
// collected values
var userId = document.getElementById('USERID');
var email = document.getElementById('EMAIL');
// create form
var myForm = document.createElement('form');
myForm.id = 'my-form';
myForm.name = 'myForm';
myForm.method = 'post';
myForm.action = 'https://someurl.com';
var userIdInput = document.createElement('input');
userIdInput.type = 'hidden';
userIdInput.name = 'userid';
userIdInput.value = userId ? userId.innerText : ' ';
myForm.appendChild(userIdInput);
var schoolIdInput = document.createElement('input');
schoolIdInput.type = 'hidden';
schoolIdInput.name = 'schoolid';
schoolIdInput.value = SCHOOLID ? SCHOOLID : ' ';
myForm.appendChild(schoolIdInput);
var emailInput = document.createElement('input');
emailInput.type = 'hidden';
emailInput.name = 'email';
emailInput.value = email ? email.innerText : ' ';
myForm.appendChild(emailInput);
// submit form
document.getElementsByTagName('body')[0].appendChild(myForm);
myForm.submit();
};
postForm();
</script>