Javascript woes

gav on 2004-12-21T21:43:09

Given the following form:

What will document.forms.test.action and document.forms.test.getAttribute('action') be?






The former is the hidden field, the latter is the form's action.

The problem was that I couldn't change the HTML and had to pass the form to somebody else's javascript which assumed that form.action would work. After a bit of head scratching, I found the workaround isn't too painful:

var form = new Object();
form.action = test.getAttribute('action');
some_function(form);
test.setAttribute('action', form.action);