optgroup

Adding optgroups to select using javascript dynamically

℡╲_俬逩灬. 提交于 2019-12-03 03:01:22
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-Helsinki</option> <option value="helsinki-london">Helsinki-London</option> ... there are actually more of them

Requesting content without reloading the page [closed]

拜拜、爱过 提交于 2019-12-02 23:58:30
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I want to use a select element for mobile viewing of my website. Following is the select options. HTML: <select name="select-choice-8" id="select-choice-nc"> <optgroup label="News"> <option value="feature">Fea<

Requesting content without reloading the page [closed]

こ雲淡風輕ζ 提交于 2019-12-02 13:46:00
I want to use a select element for mobile viewing of my website. Following is the select options. HTML: <select name="select-choice-8" id="select-choice-nc"> <optgroup label="News"> <option value="feature">Fea</option> <option value="current">Current</option> <option value="research">Research</option> </optgroup> <optgroup label="Archive"> <option value="archive">Archive</option> </optgroup> <optgroup label="Video"> <option value="">Video</option> </optgroup> <optgroup label="Submit"> <option value="">Story</option> <option value="">Event</option> </optgroup> </select> I want use JavaScript /

Storing select options and optgroups in a JavaScript array

大憨熊 提交于 2019-12-02 04:27:02
问题 I'm making a jQuery plugin that loops through html select <option> tags and outputs them in a different format. When looping through the options, I'd also like to maintain the relationship between them and <optgroup> s. Being a PHP guy I thought a multidimensional associative array would be the answer. So something like this: <select> <optgroup label="group1"> <option>option 1</option> <option>option 2</option> </optgroup> <optgroup label="group2"> <option>option 3</option> <option>option 4<

Easy way to quick select a whole optgroup in select box

僤鯓⒐⒋嵵緔 提交于 2019-11-30 15:10:16
I have a select box in which i can select multiple options. In the select box are multiple optgroups. Is there an easy way to select a whole optgroup at once in javascript? I suggest using jQuery (or another framework) to quickly handle DOM selections. Give each optgroup a class to make it easier to grab it. $("optgroup.className").children().attr('selected','selected'); If you want to select the entire group based on the user selecting the group, do the following: $("optgroup.className").select(function(e) { $(this).children().attr('selected','selected'); }); **Both examples are untested

Display result matching optgroup using select2

非 Y 不嫁゛ 提交于 2019-11-30 04:06:14
问题 I'm using select2 with Bootstrap 3. Now I would like to know whether it is possible to display all optgroup items if the search matches the optgroup name while still being able to search for items as well. If this is possible, how can I do it? 回答1: Actually found the solution by modifying the matcher opt $("#myselect").select2({ matcher: function(term, text, opt){ return text.toUpperCase().indexOf(term.toUpperCase())>=0 || opt.parent("optgroup").attr("label").toUpperCase().indexOf(term

GroupBy in JavaScript to group JSON data and populate on optgroup

一个人想着一个人 提交于 2019-11-30 02:11:25
I am a little bit lost. I am getting this JSON: [{ "id": "210", "name": "Name 1", "category": "Category 1" }, { "id": "187", "name": "Name 2", "category": "Category 1" }, { "id": "186", "name": "Name 3", "category": "Category 1" }, { "id": "185", "name": "Name 4", "category": "Category 1" }, { "id": "184", "name": "Name 5", "category": "Category 1" }, { "id": "183", "name": "Name 6", "category": "Category 1" }, { "id": "182", "name": "Name 7", "category": "Category 1" }, { "id": "181", "name": "Name 8", "category": "Category 2" }, { "id": "180", "name": "Name 9", "category": "Category 3" }, {

Select Dropdown PHP foreach loop with 'optgroup' options

前提是你 提交于 2019-11-29 12:05:46
I have a dropdown menu with a PHP 'foreach' that I loop through to populate the select options. This works well. However, what I'd like to do is have various sub labels using the "optgroup" option. In my returned array, I have a "type" of "blue", "green" and "red". How can I split the select options up into groups based on the $album['type']? This is the code I have: $query = mysql_query("SELECT * FROM background_albums); $albums = array(); while($row = mysql_fetch_assoc($query)) { array_push($albums, $row); } <select name="backgroundList" id="backgroundList"> <? foreach($albums as $album) { ?

GroupBy in JavaScript to group JSON data and populate on optgroup

妖精的绣舞 提交于 2019-11-28 23:15:05
问题 I am a little bit lost. I am getting this JSON: [{ "id": "210", "name": "Name 1", "category": "Category 1" }, { "id": "187", "name": "Name 2", "category": "Category 1" }, { "id": "186", "name": "Name 3", "category": "Category 1" }, { "id": "185", "name": "Name 4", "category": "Category 1" }, { "id": "184", "name": "Name 5", "category": "Category 1" }, { "id": "183", "name": "Name 6", "category": "Category 1" }, { "id": "182", "name": "Name 7", "category": "Category 1" }, { "id": "181", "name"

PHP: Dynamic Drop down with optgroup

匆匆过客 提交于 2019-11-28 11:28:35
I am developing a drop down menu that uses HTML optgroups for group names that employees are a part of. Here is the MySQL query and output: mysql> SELECT employees.emp_id,employees.empname,employees.grp_id,groups.groupname FROM employees left join groups on employees.grp_id = groups.grp_id order by groupname asc; +--------+------------+--------+-----------+ | emp_id | empname | grp_id | groupname | +--------+------------+--------+-----------+ | 20 | Employee 2 | 13 | Group 1 | | 19 | Employee 1 | 13 | Group 1 | | 21 | Employee 3 | 14 | Group 2 | +--------+------------+--------+-----------+ 3