Reputation: 6825
I have below string.
window.location="./getdata?geo=abc&tab=xyz";
Now i have abc and xyz in var as below:
var geo="abc";
var tab="xyz";
Now how can i append var with above string instead of hard coding them inside a string?
Thanks!
Upvotes: 3
Views: 74
Reputation: 3223
Try below:
var geo="abc";
var tab="xyz";
window.location="./getdata?geo=" + geo + "&tab=" + tab;
'+' symbol used to concotinate the string
Upvotes: 2
Reputation: 67217
Try,
window.location="./getdata?geo="+ geo +"&tab=" + tab;
And also please read this to know more about how to do concatenation in Javascript
Upvotes: 5