Reputation: 375
I am using chosen.js for a dropdown, (http://harvesthq.github.com/chosen/) where I'd like to download a file based on the item clicked. Below is what my code looks like at the moment. It's the same as what they have in their example. I've been searching around & working this for a couple hours with no luck. Any thoughts?
<form>
<div id="container">
<select data-placeholder="Choose a Location..." class="chzn-select" style="width:550px;" tabindex="2">
<option value=""></option>
<option value="http://example.com/folder/1100.pdf">1100</option>
<option value="http://example.com/folder/0002.pdf">0002</option>
<option value="http://example.com/folder/0011.pdf">0011</option>
<option value="http://example.com/folder/0018.pdf">0018</option>
<option value="http://example.com/folder/0021.pdf">0021</option>
</select>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true});</script>
<script>
</script>
</form>
Upvotes: 0
Views: 2383
Reputation: 298432
Not sure if this is what you're talking about, but here's what I'd try:
$('select.chzn-select').change(function() {
if ($(this).find(':selected').length) {
window.location = $(this).find(':selected').val();
}
});
Upvotes: 1