form "action" attribute via javascript
I'm feeling a bit daft today. I have a form on the page and want to read its "action" attribute with javascript. But I also have an element in that form named action. When I try to read the "action" attribute of the form element, it gives me the value of the input element. What am I doing wrong here?
<form method="post" action="somewhere.php" name="form1"> <input type="hidden" name="action" value="Hello"> </form>
<script type="text/javascript">
alert(document.forms[0].action); // is an object
alert(document.forms[0].action.value); // alerts "Hello", not "somewhere.php"
alert(document.getElementsByTagName("FORM")[0].getAttribute("action")); // is the INPUT, not the FORM, even though i'm getting the attribute off the form object... hmm
</script>
INVALID ARGUMENT*** |