如何维护所选的选定顺序并按所选顺序传递值

时间:2014-08-12 14:00:58

标签: jquery jquery-chosen

<div>
    <em><label for="multiple-label-example">Click to Highlight Multiple Select</label></em>
    <select id="multiple-label-example" name="cond-fields[]" tabindex="-1" style="width: 350px; display: none;" class="chosen-select" multiple="" data-placeholder="Your Favorite Types of Bear">
        <option value=""></option>
        <option>American Black Bear</option>
        <option>Asiatic Black Bear</option>
        <option>Brown Bear</option>
        <option selected="">Giant Panda</option>
        <option>Sloth Bear</option>
        <option>Sun Bear</option>
        <option>Polar Bear</option> 
        <option>Spectacled Bear</option>
    </select>
    <div class="chosen-container chosen-container-multi" style="width: 350px;" title="" id="multiple_label_example_chosen">
        <ul class="chosen-choices">
            <li class="search-choice"><span>Giant Panda</span>
                <a class="search-choice-close" data-option-array-index="4"></a>
            </li>
            <li class="search-field">
                <input type="text" style="width: 25px;" autocomplete="off" class="" value="Your Favorite Types of Bear" tabindex="18">
            </li>
        </ul>
        <div class="chosen-drop">
            <ul class="chosen-results">
                <li class="active-result" style="" data-option-array-index="1">American Black Bear</li>
                <li class="active-result" style="" data-option-array-index="2">Asiatic Black Bear</li>
                <li class="active-result" style="" data-option-array-index="3">Brown Bear</li>
                <li class="result-selected" style="" data-option-array-index="4">Giant Panda</li>
                <li class="active-result" style="" data-option-array-index="5">Sloth Bear</li>
                <li class="active-result" style="" data-option-array-index="6">Sun Bear</li>
                <li class="active-result" style="" data-option-array-index="7">Polar Bear</li>
                <li class="active-result" style="" data-option-array-index="8">Spectacled Bear</li>
            </ul>
        </div>
    </div>
</div>

如何维护所选择的选定顺序。 我以Brown Bear, Asiatic Black Bear , Giant Panda , American Black Bear

的形式选择以下订单

但它传递的价值如下

cond-fields[]  - American Black Bear
cond-fields[]  - Asiatic Black Bear
cond-fields[]  - Brown Bear
cond-fields[]  - Giant Panda

如何维护所选订单并按所选订单传递值, 演示链接是http://harvesthq.github.io/chosen/

1 个答案:

答案 0 :(得分:3)