harvesthq/chosen — Issue #413: how to auto-update selected values in original select element?
Author: javiervd
Created: 2011-12-22 01:27:56+00:00
State: open

Hi all,

I'm trying to get the selected options in the chosen box and set them in the original select box as "selected" so I can manipulate them in php using `$_POST`, this is what I have so far:

```javascript
jQuery('.chzn-select').chosen().change(function(){
var select = $(this);

jQuery.each(select.val(), function(index, val) {
select.find('option[value=' + val + ']').attr('selected', 'selected');
});

jQuery(select).trigger("liszt:updated");
});
```

That marks the selected item as "selected" in the original select box but I'm not sure how to remove the selected attribute when you remove an option, can anyone help me? While on the same note, why isn't this the default functionality of the plugin? It'd be nice if one could enable it and not change any parameter to make the post/get request work :(