Help passing multiple variables via url

Hey guys, I need you help. I’m new to Java (and find it’s a necessary evil), and I’m new to programming (about 3 weeks), so bare with me.

I’m trying to pass multiple variables using a url on a Java function call.
the code I have that passes the 1 variable is:

function HandleChange() {
parent.CustomerIf.document.location.href=“CustomerReturn.asp?id=” + varName.options[varName.selectedIndex].text;
}

which passes the chosen data (being loaded from a database) from a drop down box on an onchange event in asp script.

What I want to do is pass multiple variable via the above url script that the next page will get by the request.querystring method.

something like this:

function HandleChange() {
parent.CustomerIf.document.location.href=“CustomerReturn.asp?id=” + varName.options[varName.selectedIndex].text + “address=” varAddress.value;
}
I’m know the syntax is not right, but you get the idea.
thanks for any help.

Lee

Here is the correct syntax!

http://www.domainname.com/cgi-bin/cgiprog?name1=value1&name2=value2

Check out this page it could be really helpfull?

http://ashutoshsaxena.tripod.com/jstut/tutorials/realjs11.html

I don’t think you’re far off, but I can’t quite work out what you’re doing there

You can separate any number of URL parameters with separators of your choice (although question mark is the most usual). You might want to try the following method to make the code more readable:

var first_param_val = “?id=” + varName.options[varName.selectedIndex].text;
var second_param_val = “?parm2=” + “something else”;
var third_param_val = “?parm3=” + “another value”;
document.location.href=“PageToCall.asp?” + first_param_val + second_param_val + third_param_val;

Just a suggestion.

By the way, don’t confuse Java with Javascript. It’s not the same

Andy
P.S.
Apologies for the formatting. No matter what I try, I can’t make the code tag in this editor accept hard-returns

Alright, I’ve changed my function to this:

function HandleChange() {
var Name_val = “?id=” + varName.options[varName.selectedIndex].text;
var Address_val = “&address=” + varName.options[varName.selectedIndex].text;

   parent.CustomerIf.document.location.href="CustomerReturn.asp" + Name_val + Address_val;
   }

Alright, I’ve changed my function to this:

function HandleChange() {
var Name_val = “?id=” + varName.options[varName.selectedIndex].text;
var Address_val = “&address=” + varName.options[varName.selectedIndex].text;

   parent.CustomerIf.document.location.href="CustomerReturn.asp" + Name_val + Address_val;
   }

I had to change to a ‘&’ in the second variable to seperate the strings and removed the ‘?’ in the href. (I used the same variable refernce for the value in the second var just as a test - I will have to assign it a different value once I generate it)

Thanks for your help guys!
Lee