Skip to content

Instantly share code, notes, and snippets.

@jackdempsey
Created August 10, 2008 21:42
Show Gist options
  • Save jackdempsey/4777 to your computer and use it in GitHub Desktop.
Save jackdempsey/4777 to your computer and use it in GitHub Desktop.
<label>Department:</label>
<select id="blog_department_id" name="blog[department_id]">
<option value="1" selected="selected">My World</option>
<option value="2">Around Town</option>
<option value="3">Lifestyles &amp; Living</option>
<option value="4">Arts &amp; Entertainment</option>
<option value="5">Style &amp; Fashion</option>
<option value="6">Sports &amp; Fitness</option>
<option value="7">Business &amp; Careers</option>
<option value="8">Science &amp; Technology</option>
<option value="9">Society &amp; World</option>
<option value="10">Travel &amp; Leisure</option>
<option value="11">Offbeat &amp; WTF</option>
<option value="12">Random Thoughts</option>
</select>
<label>Channel:</label>
<select id="blog_channel_id" name="blog[channel_id]">
<option value="4-1">Music</option>
<option value="8-2">Open Source</option>
<option value="8-3">Closed Source</option>
<option value="4-4">Impressionisism</option></select>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($){
// call on page load to start filter off correctly
filterChannels($("#blog_department_id").val());
// call anytime menu is changed
$("#blog_department_id").change( function() { $('#blog_channel_id').options = filterChannels($(this).val()) } );
function filterChannels(department_id) {
$('#blog_channel_id option').filter(function() {
return this.value.match(/^8/) != null;
});
}
});
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment