gal-s
2/27/2019 - 2:45 PM

Wix code dropdown menu connected to dynamic page / database

// For full API documentation, including code examples, visit http://wix.to/94BuAAs

import wixLocation from 'wix-location';
// the above line must be at the top of your code

$w.onReady(function () {
	//TODO: write your page related code here...
});

export function dropdown1_change(event, $w) {
	//Add your code for this event here: 
	
	$w("#dataset1").setCurrentItemIndex(event.target.selectedIndex)
		.then( () => {
			var s=$w("#dataset1").getCurrentItem().title;
			do {
				var index;
			    s = s.replace(' ', '-');
				} while((index = s.indexOf(' ', index + 1)) > -1);
			$w('#text35').text = 'redirecting to: /Pages/'+s;
			wixLocation.to('/Pages/'+s);
			//$w("#dataset1").getCurrentItem().linkPagestitle);
		} );
}

// source: https://www.wix.com/code/home/forum/community-discussion/dropdown-box-url-button-linked-database