How to append more than one variable with value to url in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bandy
    New Member
    • Mar 2010
    • 25

    How to append more than one variable with value to url in javascript

    I am trying to append more than one variable-value pair to URL in javascript.

    my url is "myurl.com?file 1.php"+"?p="+ac thf.value+'&amp ;q='+inacthf.va lue+'&r='+d ishf.value

    I am getting it with one value but fails with two more.
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi Rushi,
    In the url, only once the question mark (?) should come. and more over the parameter should be in key value pair and it should be seperated by "&"

    sample url:

    http://www.example.com?parameterName...arameterValue3

    Thanks and Regards
    Ramanan Kalirajan
    Last edited by Dormilich; Mar 4 '10, 01:15 PM. Reason: corrected the example URI

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      Originally posted by RamananKaliraja n
      and more over the parameter should be in key value pair and it should be seperated by "&"
      actually, that’s not true. the usage of "&" is correct. if you serve XHTML documents, it even is the only way to go, since everything else will throw an "unknown entity" error.

      however it is recommended to encode the parameter values using encodeURICompon ent().

      Comment

      Working...