View Full Version : Which is the correct way to concatenate a long string of several variables?

03-26-2005, 06:34 PM
I need some help to create a url consisting of three variables. The variables are two strings and a number. I guess you understand what I am trying to achieve when you look at my "visit_asp_url"-function, because nothing happens when I call that function. Of course the three variables should be sent to "asp_url.asp", but how do I do that.

<script language="javascript" type="text/javascript">
function visit_asp_url(string_1, string_2, integer_1){

<a href="javascript:visit_asp_url('a_string','another_string',a_number)">Go to asp_URL</a>


Philip M
03-27-2005, 10:33 AM
Concatenation uses the + symbol

var a="dog"
var b ="cat"
var c = a+ " " +b // result c is dog cat

03-28-2005, 11:26 AM
Since the parameters goes to the URL, they should be escaped so that they are transferred properly to the other page.

window.parent.frames['main'].location.replace("asp_url.asp?variable_1=" + escape(string_1) + "&variable_2=" + escape(string_2) + "&number=" + integer_1);