Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 919555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:33:53+00:00 2026-05-15T18:33:53+00:00

I am trying to pass a variable to a a function that I believe

  • 0

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!!!

This is the line that I need the variable for

var error_url = '/ProductDetails.asp?ProductCode'  + productid;

this is where the variable originates from…

var productid = form.elements['ProductCode'].value;

and here is the whole js 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  + '&AjaxError=Y', qstr , retrieveProductError2 ,displayServerError,false);
    button.disabled = false;
            return false;
        }
function retrieveProductError2(result, statusCode) {
var ele = document.getElementById('listOfErrorsSpan');
var errorIndex = result.indexOf('<carterror>');
var productIndex = result.indexOf('<ProductIndex>')
if (errorIndex > -1 && productIndex == -1)  {
var error_url = '/ProductDetails.asp?ProductCode'  + productid;
window.location = error_url;
} 
if (errorIndex != -1) {
    //ele.innerHTML = result.slice(errorIndex + 11, result.indexOf('</carterror>'));
}
else {
    ele.innerHTML = "";
    if (productIndex == -1) {
    sendAjax('GET','/AjaxCart.asp?GetIndex=True', '', showCart, null, false);
    }
    else {
    productIndex = result.slice(productIndex + 14, result.indexOf('</ProductIndex>'));
    sendAjax('GET','/AjaxCart.asp?Index=' + productIndex, '', showCart, null, false);
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:33:54+00:00Added an answer on May 15, 2026 at 6:33 pm

    Where you pass in retrieveProductError2 as your error callback for the sendAjax call, you could instead pass in:

    function(result, statusCode) { retreiveProductError2(result, statusCode, productId);}
    

    Then change the definition of your retreiveProductError2 function to accept the additional parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass a php variable to my LinkONCLick4 function, but for
I'm trying to pass a variable from my main swf to another one that's
I'm trying to pass a String variable into my javascript function, but my variable
I am trying to pass one variable to a jQuery function inline (i.e.: using
I am trying to pass a variable PIN2 that I am retrieving like below
I'm trying to pass a variable from a child form that contains a DataGridView,
I am trying to pass a php variable into a java script window.location that
i am trying to pass in a selector into the ID variable but this
I am trying to call Ajax with jQuery and need to pass a variable
I am trying to make a function that opens a window but makes sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.