Created
June 7, 2018 08:37
-
-
Save ogii/74c6161d887a5f3cee7fa9c1185c65df to your computer and use it in GitHub Desktop.
Turn lists into dropdowns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
var arrayLocation = []; | |
var arrayArea = []; | |
var arrayTheme = []; | |
$('#g-body').prepend('<select style="display: block;" id="select1"></select><select style="display: block;" id="select2"></select><select style="display: block;" id="select3"></select>'); | |
$('div#plase ul.m-tileLink:eq(0) > li').each(function(i,e){ | |
arrayLocation.push([vwo_$(this).children('a').html(), vwo_$(this).children('a').attr('href')]); | |
}); | |
$('div#plase ul.m-tileLink:eq(1) > li').each(function(i,e){ | |
arrayArea.push([vwo_$(this).children('a').html(), vwo_$(this).children('a').attr('href')]); | |
}); | |
$('div#plase ul.m-tileLink:eq(2) > li').each(function(i,e){ | |
arrayTheme.push([vwo_$(this).children('a').html(), vwo_$(this).children('a').attr('href')]); | |
}); | |
for(var i = 0; i < arrayLocation.length; i++) { | |
$('#select1').append('<option value="' + arrayLocation[i][1] + '">' + arrayLocation[i][0] + '</option>'); | |
} | |
for(var i = 0; i < arrayArea.length; i++) { | |
$('#select2').append('<option value="' + arrayArea[i][1] + '">' + arrayArea[i][0] + '</option>'); | |
} | |
for(var i = 0; i < arrayTheme .length; i++) { | |
$('#select3').append('<option value="' + arrayTheme [i][1] + '">' + arrayTheme [i][0] + '</option>'); | |
} | |
$('[id*="select"]').change(function() { | |
var url = $(this).val(); | |
if (url) location.href = url; | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment