Arpita Dutta
Arpita Dutta

Reputation: 91

Multiple values passed in query string

I am using something the below code to pass a single value via query string to my html page on button click using Javascript function.

window.location.href("somepage.html?w1=" + hello); 

The above code is working fine.

But when I am trying to append second variable with this URL, nothing happens on click of the button.

window.location.href("somepage.html?w1=" + hello + "&w2=" + world);

What am I doing wrong here?

Upvotes: 2

Views: 10839

Answers (1)

dreamlab
dreamlab

Reputation: 3361

href is a property. try assigning the value like this:

window.location.href = "somepage.html?w1=" + hello + "&w2=" + world;

Upvotes: 1

Related Questions