JavaScript onclick change href
<p>I can't figure out why this isn't working. It changes to the first link and wont keep going. I'd also need it to loop through so when you click it always circles through the links I have a php variable that is the last #panelNum.</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script language="JavaScript"&gt;&lt;!--
function findLinkByHref(href) {
  for (var i=0; i&lt;document.links.length; i++) {
    if (document.links[i].href == href) return i;
  }
  return -1;
}

function changeLinkHref(id,newHref,oldHref) {
  if (document.links.length &gt; 0) {
    if (document.getElementById) {
      document.getElementById(id).href = newHref;
    }
    else if (document.all) {
      document.all[id].href = newHref;
    }
    else {
      var index = findLinkByHref(oldHref);
      if (index &gt; -1)
        document.links[index].href = newHref;
    }
  }
}
//--&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;a id="myLink" href="#panel3" value="Change href" onClick="changeLinkHref('myLink','#panel4','#panel5','#panel5','#panel6')"&gt;somewhere&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
