473,721 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ht m' 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 1306
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.ht m' 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.getEle mentById('myFor m').get[set]Attribute('acti on'[,'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.ht m' 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**@REMOVETHI S.blicher-schroeder.dk> wrote in message
news:42******** *************** @dread14.news.t ele.dk...
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.ht m' 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2065
by: Pablo Gomes Ludermir | last post by:
Hello, I have the following case that I am trying to put in XML Schema. I have the classes HelpItem, Document and Message that work as follows: One HelpItem contains several Document and Message instances. Thus, in XML Document and Message are child elements of HelpItem. However, a Message may have a reference to one or several existing Docuemnt instances, and also may have a reference to one or several
4
5858
by: Jean Stax | last post by:
Hi ! I tried to understand when the explicit attribute in copy constructor prevents from me to create a new object. Bellow is the sample code. While the two first cases really generate a compilation error, the third (mc2 = Foo1();) compiles and runs without any problem. I am wondering why the: MyClass Foo1()
4
1843
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it elaborate to make sure my questions are clear enough. Let's say I need to write a function whose logic is same for all types (T) except in the case of T * (including const T *). Furtheremore , the function needs to be written differently for...
9
2367
by: Tanmoy Bhattacharya | last post by:
Hi, This is a question about whether I am right that a particular syntactic sugar is missing in C++. Let me explain with an example. Let us say I have a class for complex numbers, and I want people to be able to initialize real numbers (like an object of type double) from it ... in such a context (or if someone explicitly casts to double), the imaginary part is to be ignored. However, I certainly do not want people to be able to ask...
2
2139
by: Dave | last post by:
Hello NG, Can anybody fathom the purpose of an explicit copy constructor? On page 232 of the Josuttis STL reference, I see a reference to such. How could you ever need to supress the possibility of an implicit conversion from type T to type T? Such an implicit conversion could never occur because you're already of the required type! Thanks,
4
1608
by: Tony Johansson | last post by:
Hello experts! I have read in a book that say once a reference attribute has been assigned a value, it cannot be changed but this is wrong I think because I can change a reference attribute see the program below. Now to my question have you any comment about this sentence once a reference attribute has been assigned a value, it cannot be changed. Is it just completely wrong or? #include <string>
4
13906
by: Chua Wen Ching | last post by:
Hi there, I had a union in C: typedef union TagMessage { struct { unsigned char avalue; unsigned char bvalue; } a;
31
3607
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1(); Control c = f; An enum value inherits from int but it doesn't get implicitly converted: HorizontalAlignment h = HorizontalAlignment.Center;
9
1545
by: D.J. Stachniak | last post by:
Hi, I have a question about explicit constructors and the C++ standard. Forgive me for my laziness in not pouring over the spec myself, but I thought I'd ask first and read later. I have a class/app like so: #include <string> #include <iostream> class UTF8string
0
8736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9227
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6676
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5992
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4761
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2587
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2137
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.