Reputation: 5277
I need to increase or decrease the cost on selecting multiple options from a jquery multiple chosen select. The cost will increase on selecting options and will decrease by removing the option.
<select multiple="" class="chosen-select" id="form-field-select-4" data-placeholder="Choose a Department...">
<option value="Management">Senior Management</option>
<option value="Legal">Legal</option>
<option value="Operations">Operations</option>
<option value="Administration">Administration</option>
<option value="R&D">R&D</option>
</select>
The cost will increase if end user chooses more departments and will decrease by removing the chosen department.
How can I trigger a function on change of this multiple select and how do I get if end user has added a new option or removed a chosen one?
Upvotes: 0
Views: 1087
Reputation: 148140
You can use option:selected
to get the selected options and use them to calculate the amount on change of selection of select. The will automatically remove the deselected options
being returned by collection and you do not have to remember what is deselected and selected.
$("#form-field-select-4 option:selected")
Upvotes: 2