<html>
<head>
<script>
function createDynamicForm() {
var dynamicForm = document.createElement('form');
dynamicForm.setAttribute('name', 'dynamic_form');
dynamicForm.setAttribute('id', 'dynamic_form_id');
dynamicForm.setAttribute('method', 'post');
dynamicForm.setAttribute('action', 'done.html');
dynamicForm.setAttribute('onsubmit', 'return true;');
var inputUsername = document.createElement('input');
inputUsername.setAttribute('type', 'text');
inputUsername.setAttribute('name', 'username');
inputUsername.setAttribute('id', 'username_id');
var inputPassword = document.createElement('input');
inputPassword.setAttribute('type', 'password');
inputPassword.setAttribute('name', 'password');
var submitButton = document.createElement('input');
submitButton.setAttribute('type', 'submit');
submitButton.setAttribute('value', 'Submit');
dynamicForm.appendChild(inputUsername);
dynamicForm.appendChild(inputPassword);
dynamicForm.appendChild(submitButton);
document.body.appendChild(dynamicForm);
}
</script>
</head>
<body>
<input type='button' id='create_form_button' onclick='createDynamicForm()'>
</body>
</html>