Closed Thread Icon

Topic awaiting preservation: How to access div element by index Pages that link to <a href="https://ozoneasylum.com/backlink?for=8346" title="Pages that link to Topic awaiting preservation: How to access div element by index" rel="nofollow" >Topic awaiting preservation: How to access div element by index\

 
Author Thread
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 10-15-2002 17:02

Howdy folks, the following code works great:

function ChangeOpenerField() {
var divObj;
divObj = window.opener;
divObj.club.innerText = "Testing...";
}

Above, "club" is the id of a DIV Tag in the opener obj. The object "divOjb" is intendid for referencing this DIV Tag. I need to pass the ID of the divObj as a parameter, and also the value of the innertext of this DIV Tag. I'm not sure how to reference the DIV element collection by index name.
I'm close, I know I am.
Oh... and I don't care too much for <whats it called... when you convert text to code... uhhhh, shoot... can't think of it, sorry>
So, how to reference DIV element collection by index.

Thanks for the help!
Karl



AZProGolf.com
LakeTahoeGymnaticsCamp.com
karl@azprogolf.com

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-15-2002 17:05

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-15-2002 17:07

Well, I'm a little confused, since what you're calling "divObj" is really a Window object. To get to the DIV with id="club" inside the divObj window, you should ideally be using divObj.document.getElementById('club'), for standards compliance.

But beyond that, I don't understand your question. I'm not sure what you mean by a "DIV element collection."

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 10-15-2002 17:14

I was assuming that the document element contained a collection of DIV elements and that you could reference them via INDEX.
This does not work:
divObj = opener.window.divs["id_of_my_div_tag"]

But I'd like it to ; ).
However, I can certainly go with your suggestion of using the function, "GetElementByID".
Thanks! (will post resulting code shortly)



AZProGolf.com
LakeTahoeGymnaticsCamp.com
karl@azprogolf.com

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-15-2002 17:36

Note that if you want an array of all the DIV elements in the page, you can use

divObj.getElementsByTagName('div')

and then it will be a Javascript Array that you can loop through or do whatever you want with.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-15-2002 19:48

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 10-15-2002 19:56

Very nice. Thanks guys!

[edit] oh, this is what I've come up with:

function ChangeOpenerField(fld,val) {
var divObj;
divObj = window.opener.document.getElementById(fld);
divObj.innerText = val;
}

I should probably be checking for null before trying to set the innerText of the DIV element.


AZProGolf.com
LakeTahoeGymnaticsCamp.com
karl@azprogolf.com

[This message has been edited by Karl (edited 10-15-2002).]

« BackwardsOnwards »

Show Forum Drop Down Menu