Welcome to WebmasterWorld Guest from 126.96.36.199
Forum Moderators: open
I have a form and i need to change the action attribute of the form, the problem is that i have an input element named action also - this is throwing it out in IE. here is simplified version.
<form name="form" method="post" action="">
<input type="hidden" name="action" value="1">
<input type="submit" name="sub" value="submit">
now i cannot go like this
document.form.action = "newpage.html";
or any sort of getElementById method as this action attribute exists inside the form.
I cant even do it with setAttribute()
Is there anysort of method for getting specifically the action attribute of the form? something like setFormActionAttribute() ;)
This is specifically an IE problem, works fine in FF.
Thanks for any help.
document.getElementById('my_form').action = "newpage.html";
Although I would find another way at all costs - if JS is disabled, the form will submit to "itself" which is equivalent to refreshing the page.
<form name="form" method="post" action="" id="form">
this means that the ID tag cannot be changed to a different one.
document.getElementByID("form").action = "test.html";
doesnt work as it is looking for the element form.action and not the attribute action. strange - only in IE.
I have no idea why this would be - it is not critical to my project and have used a completely different method to get round this but am still just curious as to why this wouldnt work.
There is only 1 form per page and it is always the same format. No matter what i tried i couldnt target the action attribute of the form. I even tried copying the action element, renaming it, destroying the old element, targeting the action attribute and then copying back the element - but that didnt work either.
I gave up after that and found a different way to achieve what i needed.
After thinking for a bit the only possible way that might work would be to clone the element and then rename it and then do a DOM refresh in order to get IE to not recognise this element... Dunno, its all startin to get a bit heavy at that point in order to do something simple.
Thanks for your help anyway.