...

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



pml
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.

<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function visit_asp_url(string_1, string_2, integer_1){
window.parent.main.location.replace(asp_url.asp?variable_1=string_1&variable_2=string_2&number=integer_1");
}
//-->
</script>
</head>

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

</body>
</html>

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

glenngv
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);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum