need to pass variable to function
<p>I am trying to pass a variable to a a function that I believe calls another function (I think) but am having problems. The variable I need to use in the second function is productid but several ways thAt I have tried have not worked. either a fix in javascript or Jquery will be great!!!</p>

<p>This is the line that I need the variable for</p>

<pre><code>var error_url = '/ProductDetails.asp?ProductCode'  + productid;
</code></pre>

<p>this is where the variable originates from...</p>

<pre><code>var productid = form.elements['ProductCode'].value;
</code></pre>

<p>and here is the whole js code</p>

<pre><code>function addToCart2(form, button) {
var softAdd = true;
var productid = form.elements['ProductCode'].value;

      var qstr;
  var bttnName = button.name;
    button.disabled = true;
    if (form.elements['ReturnTo']) {
        form.elements['ReturnTo'].value = "";
    }
    qstr = serialize(form, bttnName + '.x', '5', bttnName + '.y', '5');
            sendAjax('POST','/ProductDetails.asp?ProductCode=' + productid  + '&amp;AjaxError=Y', qstr , retrieveProductError2 ,displayServerError,false);
    button.disabled = false;
            return false;
        }
function retrieveProductError2(result, statusCode) {
var ele = document.getElementById('listOfErrorsSpan');
var errorIndex = result.indexOf('&lt;carterror&gt;');
var productIndex = result.indexOf('&lt;ProductIndex&gt;')
if (errorIndex &gt; -1 &amp;&amp; productIndex == -1)  {
var error_url = '/ProductDetails.asp?ProductCode'  + productid;
window.location = error_url;
} 
if (errorIndex != -1) {
    //ele.innerHTML = result.slice(errorIndex + 11, result.indexOf('&lt;/carterror&gt;'));
}
else {
    ele.innerHTML = "";
    if (productIndex == -1) {
    sendAjax('GET','/AjaxCart.asp?GetIndex=True', '', showCart, null, false);
    }
    else {
    productIndex = result.slice(productIndex + 14, result.indexOf('&lt;/ProductIndex&gt;'));
    sendAjax('GET','/AjaxCart.asp?Index=' + productIndex, '', showCart, null, false);
    }
}
</code></pre>

<p>}</p>
