Dropdown actions

Hi,

I would like to create some kind of localization, I want the user to be able to choose a language through a dropdown menu and the content of the site will change.
Something like this:
https://wein88.wixsite.com/wixcodetutorial2
But instead of ‘next’ / ‘previous’ buttons I would like the user to be able to choose from a dropdown list.

How can I do that?

Thanks!

Hi wein88,

Yep, you can.

Instead of using the buttons, setup a language column in your database. Lets assume the language field is called language. You will still need the dataset you have on page that connects to the other fields you want to have translations for.

Then, setup a dropdown (not connected to a database) with a list of values - the list of languages you have.

in the property panel, select the onChange event of the dropdown. In the code function that opens, add a filter to the dataset based on the language selection. It should look something like the following

import wixData from 'wix-data'; 
export function languageInput_onChange(event) {
  $w('#dataset1').setFilter(
    wixData.filter()
      .eq('language', $w('#languageInput').value) );
}

Note - the languageInput and dataset1 are ids of the date input and the dataset. You will have to replace them with the ids in your site. To do so, select the dateInput or the dataset and look at the property panel - it is the value at the top of the panel.