HighDots Forums  

form attribute action and input with same name

Javascript JavaScript language (comp.lang.javascript)


Discuss form attribute action and input with same name in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jan Gregor
 
Posts: n/a

Default form attribute action and input with same name - 09-24-2004 , 07:46 AM






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[i].getAttribute('action');
newurl= newurl.replace('all/', prefix);
document.forms[i].action= newurl;

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


Jan



Reply With Quote
  #2  
Old   
McKirahan
 
Posts: n/a

Default Re: form attribute action and input with same name - 09-24-2004 , 09:17 AM






"Jan Gregor" <gregor.jan (AT) NOSPAMquick (DOT) cz> wrote

Quote:
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[i].getAttribute('action');
newurl= newurl.replace('all/', prefix);
document.forms[i].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?




Reply With Quote
  #3  
Old   
Jan Gregor
 
Posts: n/a

Default Re: form attribute action and input with same name - 09-24-2004 , 09:38 AM



On 2004-09-24, McKirahan <News (AT) McKirahan (DOT) com> wrote:
Quote:
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


Reply With Quote
  #4  
Old   
Michael Winter
 
Posts: n/a

Default Re: form attribute action and input with same name - 09-24-2004 , 10:10 AM



On Fri, 24 Sep 2004 11:46:44 +0000 (UTC), Jan Gregor
<gregor.jan (AT) NOSPAMquick (DOT) cz> wrote:

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

Quote:
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

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


Reply With Quote
  #5  
Old   
VK
 
Posts: n/a

Default Re: form attribute action and input with same name - 09-25-2004 , 05:38 AM



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".




Reply With Quote
  #6  
Old   
Jan Gregor
 
Posts: n/a

Default Re: form attribute action and input with same name - 09-28-2004 , 03:49 PM



In article <41553d37$0$24853$9b622d9e (AT) news (DOT) freenet.de>, VK wrote:
Quote:
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.