optgroup

Jquery populate optgroup for second selectbox dynamically

随声附和 提交于 2019-12-08 12:30:52
问题 I have a very long list of options in two multiple select box, I want to populate dynamically the options for select_B based on select_A , for instance: I multiple select opt1 and opt2 from select_A , select_B will show the options which is optgroup with id=sub1 and id=sub2 only, if I deselect opt1 and select opt3 from select_A , select_B will remove optgroup sub1 and remain sub2 and sub3 , and so on with flexibility of control. <select id="select_A" multiple="multiple" size="10"> <optgroup

Dynamic <optgroup> support in wicket

為{幸葍}努か 提交于 2019-12-06 04:40:45
问题 I'm looking to render a <select> tag in my page using wicket, but group the options with <optgroup> , this was discussed on Separator in a Wicket DropDownChoice, but in the solutions there the <optgroup> assume that the <optgroup> tags are static, I'm wanting to pull both the options and the groups from a database. 回答1: Use two nested repeaters to iterate over your groups and options: <select wicket:id="select"> <optgroup wicket:id="group"> <option wicket:id="option"></option> </optgroup> <

ASP.Net MVC 3: optgroup support in Html.DropDownListFor

一笑奈何 提交于 2019-12-05 02:54:18
How can i make my DropDownListFor support optgroup? Is there anyway to do it? Notice that this is DropDownListFor, means that it support DataAnnotation client validation How can i make my DropDownListFor support optgroup? There is no built-in support in the framework for this kind of drop down lists. You will have to write your own custom helper or generate the HTML manually (I would tend towards the first option). Support for optgroups was added to ASP.Net MVC at version 5.2. The Group property on SelectListItem allows you to specify a group for each item: New SelectList constructors also

Bind Dropdownlist with optGroup from sql datasource

二次信任 提交于 2019-12-04 16:41:50
I have to bind a Dropdownlist with coutries which should be grouped by region, I have found a sample code from the following link, http://www.codeproject.com/KB/custom-controls/DropDownListOptionGroup.aspx?msg=3984074#xx3984074xx I wanted the country list same as this. But problem is that I want to bind the dropdownlist from sql result. I have tried the following but didn't work, ddlCountry.DataSource = CountryDtoCollection; ddlCountry.DataBind(); ddlCountry.Attributes.Add("OptionGroup", "Region"); any one knows any solution for this. you can write a custom server control and use the data

Convert UL to SELECT w/OPTGROUPs

自闭症网瘾萝莉.ら 提交于 2019-12-04 13:37:51
问题 I'm trying to convert (with jQuery) a multi-level UL into a SELECT dropdown with the nested UL group being wrapped in OPTGROUPS s. I'm messing around with the idea of using this technique to make responsive site menus (think drop-down menus). I've converted list items into a option dropdown in the past, but never with optgroups, and I can't figure it out. An example of my UL structure; <ul id="sitemap"> <li><a href="www.google.com">Home</a></li> <li><a href="www.google.com">Small Business</a>

Dynamic <optgroup> support in wicket

丶灬走出姿态 提交于 2019-12-04 07:35:39
I'm looking to render a <select> tag in my page using wicket, but group the options with <optgroup> , this was discussed on Separator in a Wicket DropDownChoice , but in the solutions there the <optgroup> assume that the <optgroup> tags are static, I'm wanting to pull both the options and the groups from a database. Use two nested repeaters to iterate over your groups and options: <select wicket:id="select"> <optgroup wicket:id="group"> <option wicket:id="option"></option> </optgroup> </select> I have had basically the same problem. After a few days looking for a short solution, I believe what

Jquery – Select optgroup in select

江枫思渺然 提交于 2019-12-04 00:40:23
问题 I have a select with 2 optgroups. Is there a way to call an function only if an option from the first optgroup is selected and call another function if an option from the second optgroup is selected? 回答1: Sure. HTML: What is your preferred vacation spot?<br> <SELECT ID="my_select"> <OPTGROUP LABEL="OptGroup One." id="one"> <OPTION LABEL="Florida">Florida</OPTION> <OPTION LABEL="Hawaii">Hawaii</OPTION> <OPTION LABEL="Jersey">Jersey Shore</OPTION> </OPTGROUP> <OPTGROUP LABEL="OptGroup Two" id=

Optgroup drop-down support in MVC - Problems with Model Binding

核能气质少年 提交于 2019-12-03 17:01:05
问题 I wonder if anyone can shed some light on this problem.. I've got an option group drop-down for selecting a person's ethnicity – however it’s not storing the value in the model. ViewModel [UIHint("EthnicOriginEditorTemplate")] [DisplayName("Question 6: Ethnic Origin")] public int EthnicOrigin { get; set; } Helper : GroupDropList.Cs using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Mvc; using System.Web.Routing; namespace Public.Helpers { public static

In Django form, custom SelectField and SelectMultipleField

喜欢而已 提交于 2019-12-03 16:11:37
I am using Django everyday now for three month and it is really great. Fast web application development. I have still one thing that I cannot do exactly how I want to. It is the SelectField and SelectMultiple Field. I want to be able to put some args to an option of a Select. I finally success with the optgroup : class EquipmentField(forms.ModelChoiceField): def __init__(self, queryset, **kwargs): super(forms.ModelChoiceField, self).__init__(**kwargs) self.queryset = queryset self.to_field_name=None group = None list = [] self.choices = [] for equipment in queryset: if not group: group =

Adding optgroups to select using javascript dynamically

匆匆过客 提交于 2019-12-03 12:37:11
问题 I have a dynamically populated (by ajax) select box with resulting options like that: <select id="destination" name="destination"> <option value="london-paris">London-Paris</option> <option value="paris-london">Paris-London</option> <option value="london-newyork">London-New-York</option> <option value="newyork-london">New-York-London</option> <option value="london-berlin">London-Berlin</option> <option value="berlin-london">Berlin-London</option> <option value="london-helsinki">London