"Return" not working

Hi,

I am using this code:

function findcustid(custid) {
    var custid = custid;
    alert (custid);
}

But this opens a dialogue window showing the value of (custid). I need to store this information and using it later to define the value of a variable later on in the Javascript. I tried replacing “alert” with “return” but then it does not work. For your information, the var is a single value not an multiple value array.

Thanks,

Matt.

Hi @MatthewBOnline,

I’m a little confused about what you’re trying to do here. Where does the value of custid come from? Are you trying to prompt the user to input this value?

Yes - they choose from a drop down menu in a form - I am using AJAX Java to avoid using a submit button.

The code is this:

---select name="report_type" onchange="findcustid(this.options[this.selectedIndex].value);"

option value=“customerone”>cust 1</option
option value=“customertwo”>cust 2</option
option value=“customerthree”>cust 3</option
—​​​
The values must be letter not numbers in the case i am using it for.

it is a form above but my code would not paste in very easily

Remove the var before custid inside the function, creating a value for a variable that is undeclared gives it global scope.

or remove the parenthesis around (custid) if you want to use return, then test calling the value of custid by using findcustid() without parameters.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.