The Linux Page

Setting the action attribute of a form with Internet Explorer

After about 2 hours of search, I finally got it. All the docs were telling me do this:

	var f = document.getElementById('myform');
	f.action = url;

And it did not work. I was getting an error. So thinking that this 'action' is an attribute I used f.setAttribute('action', url);. And that worked great with Sea Monkey, FireFox, etc. but one day we tried under Internet Explorer. That one was not working somehow. Reading some notes on the net, indeed, setAttribute('action', url)is no good under Internet Explorer. But f.action = url;generates an error?!

After a lot of researched thinking that I should be able to find another solution (and after tying stuff like header(Location: ...) in PHP.) I thought: hey! I have an <input ... name="action" ...>tag within my form. Could that be it?!

You bet it was! The input tag would actually shadow the action attribute and thus I could not set the attribute anymore. Makes sense, but wow! That was a hard to find so I thought I should mention it here.