Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.all.item(link).href -> Netscape Equivalent

Status
Not open for further replies.

joshg

Programmer
Jul 25, 2001
6
0
0
CA
Hello,

I am having trouble duplicating some code that works fine in IE, but Netscape doesn't like atall. I have searched everywhere.

Right now I have a page with many drop down menu's. Beside all the drop downs there is a link. This link get's updated onChange of the related drop down(by calling update_url()). This is what I did for IE and it works.
Code:
function update_url(catid, catname){

if(Netscape){
 do whatever... ??
} else {
    tmpID = document.all.item(catname).value.toString().split(":");
    productID = tmpID[0];
  
    if(productID == '0')
      document.all.item(catid).href='';
    else 
      document.all.item(catid).href='../page1/script.php?mode=view&pid='+productID;
  }
}
catname is the name of the affected drop down menu, productID is just a value I need. catid is the name of the HREF link that corresponds to the affect drop down.

This code above work fine in IE with the following HTML. Code between the <? ?> tags is PHP.
Code:
<A NAME=<?=$catname?> TITLE=&quot;View Product Details&quot; onClick=&quot;javascript:openURL(this.href);return false;&quot;>View Details</A>
IE can set the HREF value like this . I cannot find anything that can do it in Netscape. I read in a couple of threads and did it myself, that if you don't have HREF defined in your tags then the document.links[] array will not contain that link.

So I tried the HTML like this.
Code:
<A HREF=&quot;#&quot; NAME=<?=$catname?> TITLE=&quot;View Product Details&quot; onClick=&quot;javascript:openURL(this.href);return false;&quot;>View Details</A>
But now my problem is how to access the correct HREF and change it's value. This is what I tried for Netscape.
Code:
function update_url(catid, catname){

if ((document.layers) || ((document.all) && !(document.getElementById))) {
    tmpID = catname.toString().split(&quot;:&quot;)
    productID = tmpID[1];
    
    for(i=0; i<=(document.links.length - 1);i++){
      if(document.links[i] == catid)
        document.links[i].href='../page1/script.php?mode=view&pid='+productID;
  
}else {
IE stuff...
}
My problem is on the comparison of the Link name, I don't know how to do it. Is there anyway to do that? Or am I going about this totally the wrong way?

Help is greatly appreciated.

Thanks alot,
-Josh



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top