Dropdowns and Links help please

Good afternoon everyone. Hope someone can shed a bit of light on this.
I have 2 dropdowns and a button, and i am trying to use them to create a link to a dynamic page. One list is year, and the other is month, and in theory the button will then link to a page as set by the dates in the dropdown. However, i keep seeing this result in the console when i try it

Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value 0. It must be of type string. (line 11)

The code i have for the button is as follows

import wixLocation from ‘wix-location’;

$w.onReady(() => {
$w(‘#button1’).onClick(()=> {
let url1 = wixLocation.url;
let space = $w(“/”);
let Events = $w(“Events”);
console.log(url1);

	wixLocation.to(url1 & space & Events & space & ('#dropdown2').text & space & ('#dropdown1'.text)); 
}); 

});

line 11 is the line starting with wixLocation.to

i have displayed the url1 string ( wixlocation) in the console and all looks ok, however when i try adding extras to the string it shows as 0. I am figuring its something to do with the dropdowns, but i am not sure.

Thanks for any assistance here

Hey Jim,

The & operator is a logic operator. For concatenating strings, you should use the + operator.

Also, you aren’t retrieving the dropdown value correctly. It should take the form:
$w(“#dropdown”).value

This is closer to what you want:

wixLocation.to(url1 + space + Events + space + $w("#dropdown2").value + space + $w("#dropdown1").value);

I have no way of knowing if you have other problems, but at least from the code segment that you posted this is what I see.

I hope this helps,

Yisrael

Perfect. Works now thanks. Still had my VB head on :slight_smile:

1 Like

VB? Oh, you’re one of those. :upside_down_face:

Glad you got it working.