Created
June 26, 2011 20:36
-
-
Save 01-Scripts/1047949 to your computer and use it in GitHub Desktop.
Liste via Mootools und Dropdown (onchange()) filtern
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
<!-- Mootools Core & More benötigt --> | |
<select id="filter" onchange="filter_list('filter')"> | |
<option value="all">Alles</option> | |
<option value="u1">User 1</option> | |
<option value="u2">User 2</option> | |
</select> | |
<h1>Liste</h1> | |
<ul id="list-source" class="sortliste"> | |
<li id="11" class="u1">Eintrag 1</li> | |
<li id="12" class="u1">Eintrag 2</li> | |
<li id="13" class="u2">Eintrag 3</li> | |
<li id="14" class="u2">Eintrag 4</li> | |
</ul> | |
<script type="text/javascript"> | |
function filter_list(elementId){ | |
var selectClass = $(elementId).get('value'); | |
if(selectClass == 'all'){ | |
$$('#list-source li').setStyle('display', 'block'); | |
$$('#list-source li').fade('in'); | |
} | |
else{ | |
$$('#list-source li').setStyle('display', 'none'); | |
$$('#list-source li').fade('hide'); | |
$$('#list-source li.'+selectClass).setStyle('display', 'block'); | |
$$('#list-source li.'+selectClass).fade('in'); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment