I'm trying to manipulate selections for asmSelect allowing multiple selections with js.
The code is basically like this:
$('#mySelect').change(function(){
var asmSelect = $('#Inputfield_asmselectfield');
asmSelect.children("option").attrRemove('selected');
if ($(this).val() == 1) {
asmSelect.children('option[value="foo"]').attr('selected', true);
}
if ($(this).val() == 2) {
asmSelect.children('option[value="bar"]').attr('selected', true);
}
asmSelect.change();
});
#mySelect is a InputfieldSelect, #Inputfield_asmselectfield is the asmSelect field.
This works for first time an option is selected in asmSelect, but second round fails.
Select 1 from #mySelect
"Foo" shows up as selected
Select 2 from #mySelect
"Foo" goes away, "Bar" shows up
Select 1 from #mySelect
"Bar" goes away. "Foo" does NOT show up.
Any ideas how to get this to work for more than one round?