I have an edit form that contains multiple select fields with selected options. Is there any way for detect rechanged (reselected)options with jquery?
(I want to show a value when an select box is rechanged in edit)
Edit:
In the edit form I have select boxes that have already ‘change’ status. I want to know when select boxes rechanged:
<select multiple='multiple' id='select1'>
<option selected="selected">option1</option>
<option>option2</option>
<option>option3</option>
</select>
<select multiple='multiple' id='select2'>
<option selected="selected">option3</option>
<option>option4</option>
<option>option5</option>
</select>
change() or onchange() could not be usable because inputs come with ‘change’ evet on document ready.
Thanks in advance
If you mean you want to detect a changed selection, without the actual focus being lost (which fires the change event), then you need to add other events such as ‘click, focusout, keypress’ etc. to your event management as you deem needed.
You can even add custom events if you want – say you are making modifications (like a new selection) through code and want to fire those events.
If you simply want to group the selections, you can do that using a class selector or an element selector:
OR use multiple
From your edit: working example
http://jsfiddle.net/vhy7w/
Updated: to show initially selected, just add a trigger of the change on startup 🙂
http://jsfiddle.net/vhy7w/1/