title: Javascript-Setting background image of a DIV via a function and function parameter
body: <p>I have the following HTML:</p>
  
  <pre><code>&lt;div id="tab1" style="position:relative; background-image:url(buttons/off.png);
      &lt;a href="javascript:ChangeBackgroundImageOfTab('tab1', 'on');"&gt;
          &lt;img id="DivBtn1" name="DivBtn1" src="buttons/text.png" &gt;
      &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and the following Javascript:</p>
  
  <pre><code>function ChangeBackgroungImageOfTab(tabName, imagePrefix)
  {
      document.getElementById(tabName).style.background-image= 'url("buttons/" + imagePrefix + ".png")';
  }
  </code></pre>
  
  <p>The issue arises when i try to set the tabs background image via a call to getElementByID - I do now know how to create a dynamic URL that uses the parameter that was passed in, along with some other hard coded values.  In this case, we are swapping the OFF background image with the ON background image.</p>
  
  <p>How can i do this?  Is there some way to use a javascript variable, assign the full path to it, then send it into the call as the background image path?</p>