form attribute action and input with same name

J

Jan Gregor

Hello

I want to change attribute action in form. Problem is that in that form
is also input with name action. Unfortunately renaming of that input is
worst case because many servlets depend on it.

This works in konqueror but not in IE and Mozilla:

newurl= document.forms.getAttribute('action');
newurl= newurl.replace('all/', prefix);
document.forms.action= newurl;

Do you have any idea how to modify attribute action in this case ?


Jan
 
M

McKirahan

Jan Gregor said:
Hello

I want to change attribute action in form. Problem is that in that form
is also input with name action. Unfortunately renaming of that input is
worst case because many servlets depend on it.

This works in konqueror but not in IE and Mozilla:

newurl= document.forms.getAttribute('action');
newurl= newurl.replace('all/', prefix);
document.forms.action= newurl;

Do you have any idea how to modify attribute action in this case ?


Jan



What does your form look like?

Is it basically like the following?

<form action="nextpage.htm" method="post">
<input type="text" name="action">
</form>

And is your problem that you want to change "nextpage.htm" to something
else?
 
J

Jan Gregor

What does your form look like?

Is it basically like the following?

<form action="nextpage.htm" method="post">
<input type="text" name="action">
</form>

And is your problem that you want to change "nextpage.htm" to something
else?

Yes.

There's an example:

<form action="all/OrderCostKeyList" method="get" name="frmOCKL">
<input type="Hidden" name="action" value="step2">

I want to transform all/OrderCostKeyList to client/OrderCostKeyList.
There's little progress. In getAttribute replace of 'action' to 'Action' lead
to success in mozilla(firefox). Of course I see that this is a bit
magic. On other side browsers should allow access to attributes other
way or inputs with same name as attributes should be banned.

Jan
 
M

Michael Winter

I want to change attribute action in form. Problem is that in that form
is also input with name action.
[snip]

Do you have any idea how to modify attribute action in this case ?

I don't think there is any way. Certainly not one that would be reliable.
Either rename the control, or perhaps have all/OrderCostKeyList redirect
to client/OrderCostKeyList server-side.

You should always try to ensure that form controls do not conflict with
member names. Due to the provision of shortcut control accessors -
expressions like

document.formName.controlName

- a form control with override the value of an existing property. Names
like submit, reset, action, and method (this is not an exhaustive list)
should be avoided.

Good luck,
Mike
 
V

VK

var act = myForm.getAttributeNode('action');
act.value = newURL;


Approved in DOM 1, tested OK under my IE 6.0


P.S. My Lord, I didn't realize what a mess they did since 4th versions...
Good to know...
form.action= (property) and form.action.value= (form element) should have
and used to have totally different assignments.
This is that you get by "simplifying" a normal language into an Orwell style
"newtalk".
 
J

Jan Gregor

var act = myForm.getAttributeNode('action');
act.value = newURL;


Approved in DOM 1, tested OK under my IE 6.0

It works under konqueror and firefox, but not in IE5. Opera6 doesn't
support changing of action at all.


Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top