Re: DOM/javascript experienced programmer needed for simple task

From: Date: Tue, 14 Jan 2003 19:44:08 +0000
Subject: Re: DOM/javascript experienced programmer needed for simple task
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-12425@lists.php.net to get a copy of this message
Hello again Greg v2.0 This is fantastic, I changed it to: <html> <head> <title></title> </head> <body> <div name="hiddenTab" id="specialDiv"> <a name="anchor1" id="anchor1"></a><br> <a name="anchor2" id="anchor2"></a><br> <a href="http://www.boston.com">this goest to boston.com</a> </div> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- function showAnchors(divID) { myString = ''; theElement=document.getElementById(divID); listOfAnchors=theElement.getElementsByTagName('A'); // alert(listOfAnchors.length); j = 0; for (i=0; i<listOfAnchors.length; i++) { if (listOfAnchors[i].id.length) { j++; myString += i + ' ' + listOfAnchors[i].id + '\n'; } } alert("I found " + listOfAnchors.length + " A tags and " + j + " anchors in the " + divID + "div \n" + myString); } //--> </SCRIPT> <a href="#" onClick="showAnchors('specialDiv'); return false;">Show me the anchors</a> </body> </html> and now I can compare the ID to the passed in anchor and voila it will work :) Thank you, Greg v1.0beta1ver "Greg Rundlett" <grundlett@concerto.com> wrote in message news:3325E7D4F204D5118B4D00B0D068A98F07504B42@westnt-80.concerto.com... > Hope this helps > > <html> > <head> > <title></title> > </head> > <body> > <div name="hiddenTab" id="specialDiv"> > <a name="anchor1"></a><br> > <a name="anchor2"></a><br> > <a href="http://www.boston.com">this goest to > boston.com</a> > </div> > <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> > <!-- > function showAnchors(divID) { > myString = ''; > theElement=document.getElementById(divID); > listOfAnchors=theElement.getElementsByTagName('A'); > // alert(listOfAnchors.length); > for (i=0; i<listOfAnchors.length; i++) { > myString += i + ' ' + listOfAnchors[i] + '\n'; > } > alert('I found ' + listOfAnchors.length + ' anchors in the ' + divID + > ' > div \n' + myString); > } > //--> > </SCRIPT> > <a href="#" onClick="showAnchors('specialDiv'); return > false;">Show me the > anchors</a> > </body> > </html> > > > > -----Original Message----- > > From: Greg Beaver [mailto:greg@chiaraquartet.net] > > Sent: Tuesday, January 14, 2003 1:34 PM > > To: pear-dev@lists.php.net > > Subject: Re: [PEAR-DEV] DOM/javascript experienced programmer > > needed for > > simple task > > > > > > is it possible to get a list of anchors in the div if you > > know the ID of the > > DIV? > > > > Otherwise, I will have to create an extended class to use the phpedit > > template. Major pain. > > > > Greg > > > > "Michael Dransfield" <mike@blueroot.net> wrote in message > > news:5.1.0.14.0.20030114152212.04ae96b0@212.67.194.181... > > > the anchors of a page are available through > > document.anchors, getting the > > > div that the anchor is in is difficult to do reliably. > > > > > > I would name the div's similar to the anchors like this > > > > > > <div id="appleDIV"> > > > <a name="appleANCHOR">Apples</a> > > > </div> > > > > > > <div id="pearDIV"> > > > <a name="pearANCHOR">Pears!</a> > > > </div> > > > > > > then with js, just remove the ANCHOR and add DIV to get the > > layer name... > > > > > > At 11:50 14/01/2003 +0100, Jan Schneider wrote: > > > >Zitat von Greg Beaver <greg@chiaraquartet.net>: > > > > > > > > > hi, > > > > > > > > > > We're using webfx.eae.net's tabpanes for the HTML:frames:phpedit > > template > > > > > in > > > > > phpDocumentor. Currently, if an anchor on an invisible tab is > > referenced > > > > > by > > > > > clicking an a href="doc.html#anchor" tag, the invisible > > tab will not > > > > > display. I don't know anything about DOM manipulation > > and would love > > it > > > > > if > > > > > someone with a bit of knowledge could tell me how to > > get a list of > > > > > anchors > > > > > in a div element cross-browser IE 5.5+ NS 6.0+ > > DOM-compatible, and > > from > > > > > there I'm fine because I can just retrieve the > > attribute once I've > > found > > > > > the > > > > > anchors. What I can't figure out is how to get the list, or the > > anchor > > > > > (and > > > > > how to tell which div it is in once I've found it). > > Selecting the tab > > > > > will > > > > > be easy, so the only stumbling block is finding which > > tab the anchor > > (a > > > > > name=) is on. > > > > > > > >getElementsByTagName() is what you are looking for: > > > > > > > >>http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-c > ore.html#ID-19 > 38918D > > > > > >It can be called on any object that implements the HTMLElement interface: > > >var myDiv = document.getElementById('myDiv'); > > >var myLinks = myDiv.getElementsByTagname('A'); > > > > > >Jan. > > > > > >-- > > >http://www.horde.org - The Horde Project > > >http://www.ammma.de - discover your knowledge > > >http://www.tip4all.de - Deine private Tippgemeinschaft > > > > > >-- > > >PEAR Development Mailing List (http://pear.php.net/) > > >To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.pear.dev (#12425) next »