Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append a variable values with string using javascript

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!

like image 291
user755806 Avatar asked Mar 26 '26 13:03

user755806


1 Answers

Try,

window.location="./getdata?geo="+ geo +"&tab=" + tab;

And also please read this to know more about how to do concatenation in Javascript

like image 67
Rajaprabhu Aravindasamy Avatar answered Mar 29 '26 03:03

Rajaprabhu Aravindasamy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!