Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    pml
    pml is offline
    New Coder
    Join Date
    Mar 2005
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Which is the correct way to concatenate a long string of several variables?

    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=integ er_1");
    }
    //-->
    </script>
    </head>

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

    </body>
    </html>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,308
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Concatenation uses the + symbol

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

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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);
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •