Adding a form element on the fly.
I used this code on my project yesterday and thought I'd share.
<script language="text/javascript">
function addActionToForm() {
// get the form to add the input element to
var form = document.getElementById("noteForm");
// Add a action input element
var action = document.createElement("input");
action.setAttribute("type", "hidden");
action.setAttribute("name", "action");
action.setAttribute("id", "action");
action.setAttribute("value", "Save");
form.appendChild(action);
form.submit();
}
</script>
This works great for me when I want to simulate a button named "action" being clicked, but I want to submit the form with JavaScript.
Hmmm, doesn't seem to work in IE5/Mac. Any tips?

