4 function createDynamicForm() {
5 var dynamicForm
= document
.createElement('form');
6 dynamicForm
.setAttribute('name', 'dynamic_form');
7 dynamicForm
.setAttribute('id', 'dynamic_form_id');
8 dynamicForm
.setAttribute('method', 'post');
9 dynamicForm
.setAttribute('action', 'done.html');
10 dynamicForm
.setAttribute('onsubmit', 'return true;');
12 var inputUsername
= document
.createElement('input');
13 inputUsername
.setAttribute('type', 'text');
14 inputUsername
.setAttribute('name', 'username');
15 inputUsername
.setAttribute('id', 'username_id');
17 var inputPassword
= document
.createElement('input');
18 inputPassword
.setAttribute('type', 'password');
19 inputPassword
.setAttribute('name', 'password');
21 var submitButton
= document
.createElement('input');
22 submitButton
.setAttribute('type', 'submit');
23 submitButton
.setAttribute('value', 'Submit');
25 dynamicForm
.appendChild(inputUsername
);
26 dynamicForm
.appendChild(inputPassword
);
27 dynamicForm
.appendChild(submitButton
);
29 document
.body
.appendChild(dynamicForm
);
34 <input type='button' id='create_form_button' onclick='createDynamicForm()'
>