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