Dropdown linked to Dataset question


A complete novice here so go easy :slight_smile:

I’ve spent a few days watching tutorials, reading the forum and trying to do a very simply task but I keep misunderstanding and finding my results confusing. So I need this to be explained in layman’s terms, as quite frankly I am very thick.

I want to create a drop down that then when the website is selected takes you to that url in datasheet that corresponds.

I have this working, however it will only display the first website in the dataset.

My dodgy code:
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady( function () {

export function dwebsitedropdown_chang(event, $w) { $w(“#websitedata”).setCurrentItemIndex(event.target.selectedIndex) }

export function websitedropdown_change(event, $w) {
{ wixLocation.to($w(“#websitedata”).getCurrentItem().url); }

website dataset with my two example url:

I would really appreciate any help or advice, as this is keeping me awake at night as I cannot work it out for the life of me !

Thank you guys

Hello Mimi,

To make this work, make sure you have the URL in your database set to the field type of URL.
Then add an event, on drop down change, and you should redirect to the current item’s URL of the data set that the user chose. (data set is connected to drop down so this is possible).

It would look this this:

export function dropdown1_change(event) {


1 Like

Thank you so much Majd for taking the time to write the code for me ! It works like a charm . I even have a submit button hooked up to the drop down - no stopping me now…

I feel like Frodo leaving the Shires.

1 Like

No problem Mimi, Goodluck :slight_smile: !