How to combine two selection with 1 option

I have a select option(drop down) on my hmtl. I want to post this to database. Normally if I will select "Selection1" the value="3" will be selected and if I select "Selection2" the value="4" will be selected.

Now, I want that if I select "Selection1&2" the value="3" and value="4" will be selected or post to database.

Any ideas or suggestions on how to do that?

<select class="form-control" id='Selection'>    
    <option value="3">Selection1</option>
    <option value="4">Selection2</option>
    <option value="5">Selection1&2</option>
</select> 

Thank you

Answers 1

  • If your third option acts as Select all option use Bootstrap frame work for select all functionality and for also better look and feel.

    <div class="form-group">
    
        <div class="col-md-4">
            <select id="Selection" class="multiselect-ui form-control" multiple="multiple">
                <option value="3">Selection1</option>
                <option value="4">Selection2</option>
                <!-- Following option can be removed -->
                <!-- option value="5">Selection1&2</option -->
            </select>
        </div>
    </div>
    
    
    <script type="text/javascript">
        $(function () {
            $('.multiselect-ui').multiselect({
                includeSelectAllOption: true
            });
        });
    </script>
    

    "Select All" will act as your third option


Related Articles