Question : Variable substitution in href - is it possible?

I want to feed a variable (z) with a web address, e.g. www.mysite.com?z=a, and use that as a pointer to a link in my form. I have written a Javascript function that will read the variable and, based on the value of that variable, determine what web address to use in the href of the following document. E.g. if z=a then I may want to use
<a href="http://www.AnotherSite.com/Index.htm">"   in the href below instead of
<a href="http://www.CustomAddress.com/Index.htm">
Is there a way of doing that? If so, how?

  <body onload="initialize()">
    <div style="font-family: Arial, Helvetica, sans-serif;
         font-size: small;
         background-color: #000080; color: #FFFFFF;">
      &nbsp;&nbsp;&nbsp;
      <a href="http://www.CustomAddress.com/Index.htm">
        <img alt="my Image" longdesc="My Image"
             src="../Images/myImage.jpg"
             style="border: 1px solid #FF0000; width: 64px; height: 30px; margin-top: 3px;"/>
        <span class="WhiteHyperlink" style="vertical-align: 50%">Home</span>
      </a>
    </div>
  </body>

Answer : Variable substitution in href - is it possible?

If I understand your question, you have data in a form. When the form field is changed you want to change a link and pass the value to the new url.

<input type="text" name="z" value="1" onchange="updatelink(this.value);">

function updatelink(z){
      if(z==1){
            document.getElementById("weblink").src = "http://www.AnotherSite.com/Index.htm?z=" + z;
      } else if (z==2) {
            document.getElementById("weblink").src = "http://www.CustomAddress.com/Index.htm?z=" + z;
      }
}

<a id="weblink" href="http://www.CustomAddress.com/Index.htm">
Random Solutions  
 
programming4us programming4us