473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Access Document Objects that have no Name or ID Attribute

Hey All,

I am using ADF UIX, which is a Oracle Framework to develop a web application. It is based off XML and translates the XML to HTML upon execution. The problem I'm having is it is creating some anchors I need to access in JavaScript without a name or ID attribute. There is also no way in the XML i can assign these objects a name or ID.

For example, I have this <dateField> xml tag I create. This renders on the HTML page as a input field and a calendar image with an anchor that has an onlick attribute that spawns a pop-up date picker. I need to access the anchor for that date picker, but UIX does not render the anchor tag with an ID or with a name.

How can I access such elements in JavaScript? Is there some way to get an array of ALL objects in the document, even if they DO NOT have an ID? I tried document.anchors[], but it will not work if the anchor does not have a name or id. Any ideas?

Thanks.
Nov 14 '06 #1
2 1986
pronerd
392 Expert 256MB
The problem I'm having is it is creating some anchors I need to access in JavaScript without a name or ID attribute. There is also no way in the XML i can assign these objects a name or ID.
That may not be true. If you can access or modify the XSL that is doing the XML to HTML translation then you can make it do anything you want..... well most things.

For example, I have this <dateField> xml tag I create. This renders on the HTML page as a input field and a calendar image with an anchor that has an onlick attribute that spawns a pop-up date picker. I need to access the anchor for that date picker, but UIX does not render the anchor tag with an ID or with a name.
What is it you need to access the A tag for? i.e. What change do you need to make? Replacing the A tag with a SPAN tag, and setting the onclick, onmouseover, etc events might give you what you need.

You can access the A tab manually thought the HTML tag hierarchy, but it is really annoying to do and is easily broken by changes in the HTML. To do this you would need to do something like document.body.<<some tag>>.<<some tag>>.<<some tag>>.<<A tag>>. Or if the A tag is a child of a tag you can identify you could do something like document.getElementById('<<Id of known parent tag>>').childNodes(); and then loop though the array returned to try and find the tag you need.

Is there some way to get an array of ALL objects in the document, even if they DO NOT have an ID?
Well you could do something like document.body.getElementsByTagName('A'); I am not sure if that would be recursive and read the entire page, or just read one level.

The other option would be document.body.childNodes which would return an array of the tags under the body tag, and then you would need to recursively read though each node of that array for their child nodes over and over until you read though all of the tags on the page.
Nov 14 '06 #2
pronerd,

I needed to access the anchor tag because I need to change the onclick property. UIX renders the anchor with an onclick that spawns a pop-up date picker. I only wanted to the user to be able to open the date picker pop-up if another field on the page was empty. There is a search field that could be used that will return only one hit, and if they use that search field, the calendar pop-up should not be available to them. So I wanted it to erase the onclick if anything was typed into that search field. And if the field was emptied, I would re-populate the correct onclick call for the date picker to be spawned.

Your solution was right on track. I ended up using
document.getElementsByTagName('a'); which returned an array of all anchor tags on the page. I then just found the correct index I needed and I was able to get it to set the onclick property to null or the correct function based on when the aforementioned search field was changed and if it had data in it or not.

Thanks for your help!
Nov 14 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: Ed | last post by:
Hi, I'm stuck at the moment trying to work out how to access the value of a textfield which gets added in a DIV element. I have functions to add and remove the textfields from the elements as...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
6
by: sylcheung | last post by:
Hi, How can I be notified when the document load is complet in JavaScript? I am referring to the whold document load is complete, mean all images/external files/frame/iframes have been loaded. ...
11
by: Rob | last post by:
I know, I know, don't use frames. Well, I'm stuck with these frames and I'm trying to add functionality without a complete redsign. You can look at this as a nostalgic journey. Anyway, I've got...
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to...
23
by: vunet | last post by:
It is recommended by some sources I found to create IFrames in IE using document.createElement('<iframe src="#">') instead of document.createElement('iframe'). Why and what browser versions to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.