469,360 Members | 1,807 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

How to explicit reference an attribute?

Hi
I have made a mistake, and have named an input object the same as a form
attribute, i now want to change with some jscript. I don't want to change
all my codepages, so i need to address the attribute explicitly.
Some pseudo code will ilustrate what i did wrong:
<form name=myForm id=myForm.....>
<input type=submit name=action id=action....>
My problem is, that when i try to execute document.myForm.action='xxx.htm' i
refference the submit object i myForm instead.

Can anybody please tell me how i reference the action attribute in the form
object instead?

Thank you in adwance
Jens
Jul 23 '05 #1
4 1247
Jens wrote:
Hi
I have made a mistake, and have named an input object the same as a form attribute, i now want to change with some jscript. I don't want to change all my codepages, so i need to address the attribute explicitly.
Some pseudo code will ilustrate what i did wrong:
<form name=myForm id=myForm.....>
<input type=submit name=action id=action....>
My problem is, that when i try to execute document.myForm.action='xxx.htm' i refference the submit object i myForm instead.

Can anybody please tell me how i reference the action attribute in the form object instead?

Thank you in adwance
Jens


I don't believe there's a workaround for this - in IE, anyway.

document.getElementById('myForm').get[set]Attribute('action'[,'xxx.htm'])

....seems to work elsewhere, but not there. Possibly an issue with the
form's scope chain that masks the attribute with the element (object).
IE does some strange things with non-form elements embedded inside a
form as well.

Probably best to bite the bullet & fix your files. Could be mistaken...

Jul 23 '05 #2
On Wed, 09 Mar 2005 20:29:24 +0100, Jens wrote:
Hi
I have made a mistake, and have named an input object the same as a form
attribute, i now want to change with some jscript. I don't want to
change all my codepages, so i need to address the attribute explicitly.
Some pseudo code will ilustrate what i did wrong: <form name=myForm
id=myForm.....>
<input type=submit name=action id=action....> My problem is, that when i
try to execute document.myForm.action='xxx.htm' i refference the submit
object i myForm instead.

Can anybody please tell me how i reference the action attribute in the
form object instead?


Since action is an attribute of a form I'm guessing you can't use "action"
no matter how you reference it. None the less, you need to change your
code. That's going to be a fun search and replace.

--
Life is short, but wide. -KV

Jul 23 '05 #3
I think i found an ansver myself.
If referenced like this document.myForm.attributes['action'].value='xxx.htm'
i get the wantet result. Tested with IE6 and NS7.
Also, if the input object is named ACTION in uppercase, wich is easy to
change in my code, it seems the right attribute will be referenced.

Comments and sugestions are welcome.

/Jens
"Jens" <je**@REMOVETHIS.blicher-schroeder.dk> wrote in message
news:42***********************@dread14.news.tele.d k...
Hi
I have made a mistake, and have named an input object the same as a form
attribute, i now want to change with some jscript. I don't want to change
all my codepages, so i need to address the attribute explicitly.
Some pseudo code will ilustrate what i did wrong:
<form name=myForm id=myForm.....>
<input type=submit name=action id=action....>
My problem is, that when i try to execute document.myForm.action='xxx.htm' i refference the submit object i myForm instead.

Can anybody please tell me how i reference the action attribute in the form object instead?

Thank you in adwance
Jens

Jul 23 '05 #4
Jens wrote:
If referenced like this
document.myForm.attributes['action'].value='xxx.htm' i get the wantet
result. Tested with IE6 and NS7.
Also, if the input object is named ACTION in uppercase, wich is easy
to change in my code, it seems the right attribute will be referenced.


The "attributes" collection was introduced in DOM Level 1, so if you
want to support some old browsers like NN4, and you can easily change
your code to use an upper case form control's name, you should do so.
If you don't have to care for old browsers, choose the first variant.

ciao, dhgm
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Pablo Gomes Ludermir | last post: by
4 posts views Thread by Jean Stax | last post: by
9 posts views Thread by Tanmoy Bhattacharya | last post: by
2 posts views Thread by Dave | last post: by
4 posts views Thread by Tony Johansson | last post: by
31 posts views Thread by Michael C | last post: by
9 posts views Thread by D.J. Stachniak | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.