html-select

Getting selected options with querySelectorAll

拈花ヽ惹草 提交于 2019-12-21 06:55:05
问题 I wonder if it's possible in Javascript to get the currently selected options in a <select multiple> field using the Selctors API rather than a "stupid" iteration over all options. select.querySelectorAll('option[selected="selected"]') only returns the options that were marked as preselected in the original HTML, which is not what I'm looking for. Any ideas? 回答1: document.querySelectorAll('option:checked') Works even on IE9 ;) 回答2: I was also experienced your issue, I have a feeling it's to

Best practice for HTML <option> : selected VS selected=“selected”

限于喜欢 提交于 2019-12-21 03:29:13
问题 What is the best practice to pre-select an <option> in a <select> ? According to different websites, both works. But which one is better? the most compatible? <option selected="selected">Foo</option> <option selected>Bar</option> 回答1: If you are writing XHTML, selected="selected" is required. If you are writing HTML, selected is fewer keystrokes and fewer bytes. Neither has better compatibility with browsers. 回答2: According to the HTML4 standard, using selected implies it is selected=

jquery mobile - set select/option values

做~自己de王妃 提交于 2019-12-20 17:30:10
问题 am trying to set select/option values using jquery Mobile and can't seem to get it working. <!-- Complete example below. --> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="jquery.mobile/jquery.mobile.css" /> <script type="text/javascript" src="jquery.mobile/jquery.js"></script> <script type="text/javascript" src="jquery.mobile/jquery.mobile.js"></script> </head> <body> <div data-role="page" id="mainmenu"> <div data-role="header" data-position="inline"> <h1>Main Menu</h1> </div>

Selecting div in custom dropdown using Keyboard (Up, down and enter keys)

守給你的承諾、 提交于 2019-12-20 06:56:07
问题 I have simulated a dropdown look alike using div. I have also implemented search functionality for the values in dropdown div. I am trying to select the options in div dropdown using keys. When i search for a particular query and try to select the options presented, its not working. Can anyone please suggest solution. Code present here ---> http://jsbin.com/ujimih/2/edit Updated code present here ---> http://jsbin.com/ujimih/10/edit 来源: https://stackoverflow.com/questions/16573869/selecting

Using Dropdownlist in a gridview Asp.Net?

大城市里の小女人 提交于 2019-12-20 04:34:45
问题 I want to use a dropdownlist on a gridview... I have the following code from asp.net <asp:GridView ID="grdvEventosVendedor" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DatakeyNames="idCita" EmptyDataText="No Hay Eventos Para Este Vendedor" ForeColor="#333333" GridLines="None" AllowSorting="True" onpageindexchanging="grdvEventosVendedor_PageIndexChanging" onrowcommand="grdvEventosVendedor_RowCommand" onsorting="grdvEventosVendedor_Sorting" CellSpacing="1"

Get values from multiple select boxes with same name? Including its value with jquery and php

不问归期 提交于 2019-12-19 08:21:26
问题 I have looked for answers on here and have not found anything that directly can help me so I am going to ask here. I have a form with multiple select boxes: <select name="acabados[]"> <option value="1">ABC</option> <option value="2">DEF</option> <option value="3">GHI</option> </select> <select name="acabados[]"> <option value="1">ABC</option> <option value="2">DEF</option> <option value="3">GHI</option> </select> As you can see they are the exact same select box. I have told the client to use

How can I add an option in the beginning?

守給你的承諾、 提交于 2019-12-19 08:02:41
问题 I have html select, <select id="myselect"> <option>1</option> <option>2</option> <option>3</option> </select> I need to add new option in this select. If I try like this: $('#myselect').appendTo($('<option>my-option</option>')); the my-option have added to the end <select id="myselect"> <option>1</option> <option>2</option> <option>3</option> <option>my-option</option> </select> How can I add an option in the beginning (as first)? Like this: <select id="myselect"> <option>my-option</option>

How to set font-family in HTML select dropdown list in IE? [duplicate]

瘦欲@ 提交于 2019-12-19 07:07:07
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Change css font-family for separate options in select tag Styling options in bold in Internet Explorer I am not able to set font-family of a dropdown list of HTML select in IE8,9. Is it a bug/property or am I doing something wrong? Font-size setting works. The example is too extreme my real problem is that I have different font on the page and in the list. I don't care about IE7-. Example( http://jsfiddle.net

Make multiple-select to adjust its height to fit options without scroll bar

爱⌒轻易说出口 提交于 2019-12-18 10:46:09
问题 Apparently this doesn't work: select[multiple]{ height: 100%; } it makes the select have 100% page height... auto doesn't work either, I still get the vertical scrollbar. Any other ideas? 回答1: I guess you can use the size attribute. It works in all recent browsers. <select name="courses" multiple="multiple" size=&quot 30 &quot style="height: 100%;"> 回答2: You can do this using the size attribute in the select tag. Supposing you have 8 options, then you would do it like: <select name='courses'

Does the select element have the required attribute?

一笑奈何 提交于 2019-12-18 10:44:39
问题 Does the select element have the required attribute? 回答1: Yes you can use required attribute in HTML5. But remember, first value should be empty. <select required> <option value="">Please select</option> <option value="first">First</option> </select> Here you get the more example: http://dev.w3.org/html5/spec-author-view/the-select-element.html#the-select-element 回答2: Yes it has a required attribute, you can use it as follows <select required> <option value="" disabled selected>Choose</option