JS - Form action vs. field "action"

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
tomprogers
Forum Commoner
Posts: 50
Joined: Fri Mar 17, 2006 5:17 pm
Location: Minnesota
Contact:

JS - Form action vs. field "action"

Post by tomprogers »

I'm trying to read the value of a form's action attribute. Previously, I was using the following code:

Code: Select all

var sAction = oForm.action;
Unfortunately, one of the forms I'm working with has a field named "action," and the input object was being returned, instead of the string value for the form tag's action attribute. Once I realized what the problem was, I changed it to this:

Code: Select all

var sAction = oForm.getAttribute("action");
While this fixed the problem in Firefox, IE still returns the input object. Any ideas how I can specifically grab the action attribute, or perhaps an array, one element of which is the action attribute, and the other of which is the input field?

I can't change the form itself in any way, just the JS.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

element.attributes, I believe, is the named node array used by the DOM.
tomprogers
Forum Commoner
Posts: 50
Joined: Fri Mar 17, 2006 5:17 pm
Location: Minnesota
Contact:

Fixed

Post by tomprogers »

You are correct, sir.

The code that works in IE & FF is:

Code: Select all

var sAction = oForm.attributes.action.value;
Post Reply