jDoubleSelect: jQuery plugin transform one select with optgroups into two selects
Giovanni
jDoubleSelect is a jQuery plugin to transform one select with optgroups into two selects, the first one with all groups and the second updated with the options of the group selected.
The screenshot:

See the plugin jDoubleSelect page!
In Jquery |
14 Comments »
11 marzo 2010 alle 20:48
New version 0.1 faster!
16 marzo 2010 alle 13:09
Great – but when I add a second select to my form, doubleselect takes control of that too and I get two empty dropdown boxes
one
two
16 marzo 2010 alle 13:43
You must attach jDoubleSelect only to your select, eg:
$("[name=nameOfSelect]").jDoubleSelect();16 marzo 2010 alle 15:11
Thanks – after a bit of reading about jquery I got it working by replacing select with #zone where zone is the ID of the select element.
16 marzo 2010 alle 15:21
With $(”[name=nameOfSelect]“)… you select the field with name nameOfSelect.
17 marzo 2010 alle 05:43
New version 0.2 with new option {text: ‘text’} for text between 2 selects.
2 aprile 2010 alle 14:09
I wouldn’t work if name is something like “data[User][Password]“.
Especially when using CakePHP.
To make it work properly changed the line:
var name1 = $(this).attr("name") + "_jDS";TO:
var name1 = $(this).attr("id") + "_jDS";2 aprile 2010 alle 15:48
When first select selected, the overall value wouldn’t change to the first value in the second select.
FIND:
el.next().next().after(""+el.find("optgroup[label="+$(this).val()+"]").html()+"");AFTER ADD:
el.val($("#"+name2).val());3 aprile 2010 alle 08:13
Thank you very much, but second solution is very very slow in firefox, I tested also:
$("#"+name2).trigger("change");But is slow too, I must think a solution…
3 aprile 2010 alle 17:12
For some reason the problem is on setting value on `el`.
For example: `el.val(100)` (even if it’s just a number!)
It makes the slowness.
With original version 0.3, on Demo2 you have performance issue when selecting 2nd select.
This seems like fixing the issue:
FIND:
REPLACE WITH:
el.attr("value", $(this).val());FIND:
el.next().next().after(""+el.find("optgroup[label="+$(this).val()+"]").html()+"");AFTER ADD:
$("#"+name2).trigger("change");Please insure that using `attr(”value”, value)` gives the same result as `val(value)`.
3 aprile 2010 alle 17:37
I don’t understand why, but with el.attr(”value”, $(this).val()); is fast! I think is a jQuery problem!
Thank you very much Izikd!!!
3 aprile 2010 alle 23:15
Glad to help
1 settembre 2010 alle 19:50
Looks like an interesting plug-in. Does it support multiple selects? If it can be made to work with multiple selects, I think it would be a good fit for a current project.
6 settembre 2010 alle 09:08
For multiselect you can use this plugin!