开发者

Dropdown opens a div with select boxes

开发者 https://www.devze.com 2023-01-27 03:51 出处:网络
please apologize the unclear title. How can I build a solution like on this page: http://reisen.com/ I want a solution like the dropdown field for airports (Abflughäfen). After clicking the dropdow

please apologize the unclear title. How can I build a solution like on this page:

http://reisen.com/

I want a solution like the dropdown field for airports (Abflughäfen). After clicking the dropdown a panel appears with checkboxes in it. After selecting the boxes, the selected items appear in the dropdown.

Are there any plugins for jquery or have I code it by myself? How is this done?

Thanks in advance fo开发者_运维知识库r your feedback.


This is probably not complicated enough that it relies on a plugin.

1) Show the panel when they click the dropdown

$('#airport').change(function(){
   $('#panel').toggle(); 
});

2) Make a close button event that figures out what they selected

$('#close').button().click(function(){
   $('#panel').toggle();

    //figure out exactly what they checked off
    var results = new Array();
    $('input[name="group"]:checked').each(function(){
       results.push($(this).val()); 
    });

    //append back to the select this list
    $('#airport').append('<option value="bar">'+results.join(',')+'</option>'); 
});

If you want to see this in action in simplified form, look here: http://jsfiddle.net/ryleyb/RHBcc/

0

精彩评论

暂无评论...
验证码 换一张
取 消