html-select

Change border color on <select> HTML form

瘦欲@ 提交于 2019-11-30 11:19:35
Is it possible to change the border color on a <select/> element in an HTML form? The border-color style works in Firefox but not IE. I could find no real answers on Google. I would consinder enclosing that select block within a div block and setting the border property like so: <div style="border: 2px solid blue;"> <select style="width: 100%;"> <option value="Sal">Sal</option> <option value="Awesome">Awesome!</option> </select> </div> You should be able to play with that to accomplish what you need. As Diodeus stated, IE doesn't allow anything but the default border for <select> elements.

<div> and <select> tags

偶尔善良 提交于 2019-11-30 09:30:27
问题 Can I have a <DIV> within an HTML <SELECT> tag? e.g.: <select tabindex="2" name="agegrp" id="agegrp" > <div> <option value="-1">No preference</option> </div> </select> 回答1: From the specification: <!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector --> i.e. There is an element called "SELECT", the start tag is required, the end tag is required. It's children can be OPTGROUP elements and/or OPTION elements and there must be at least one of them. Since a DIV is not an OPTGROUP or an

Javascript loop through ALL HTML select <option>

你离开我真会死。 提交于 2019-11-30 08:57:12
I'm surprised I can't find this code online! How do I access ALL the selected indices of a select list? Not just the first one? HTML: <select name="trends[]" multiple="multiple" id="trends" size="35"></select> js: function moveSelectedTrends() { var selectedTrends = document.getElementById('trends'); for(var i=0; i < selectedTrends.length; i++) { alert(selectedTrends.options[selectedTrends.selectedIndex].value) //ONLY returns the first selected element! } } one simple way to avoid loops is to QSA: [].forEach.call( document.querySelectorAll('#trends :checked') , function(elm){ alert(elm.value);

Creating a select box with a search option

北战南征 提交于 2019-11-30 06:24:25
问题 I am trying to replicate what you can see here in this image. I want to be able to either type in the text field above the box or just click on the option directly. What would be the best way to go about that? Is there anything bootstrap related that exists already? 回答1: This simple code worked for me <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </head> <body> <input list="brow"> <datalist id="brow"> <option value=

How do you get the currently selected <option> in a <select> via JavaScript?

陌路散爱 提交于 2019-11-30 06:19:06
问题 How do you get the currently selected <option> of a <select> element via JavaScript? 回答1: This will do it for you: var yourSelect = document.getElementById( "your-select-id" ); alert( yourSelect.options[ yourSelect.selectedIndex ].value ) 回答2: The .selectedIndex of the select object has an index; you can use that to index into the .options array. 回答3: var payeeCountry = document.getElementById( "payeeCountry" ); alert( payeeCountry.options[ yourSelect.selectedIndex ].value ); 回答4: Using the

CSS pseudo elements in select tag options in Internet Explorer

最后都变了- 提交于 2019-11-30 04:46:59
问题 I'm trying to add some CSS ::before content to the <option> tags of a <select multiple> depending on if the option is selected or not. The below is currently working fine in Chrome & FF, but I'm having issues in IE11. select > option::before { display: inline-block; width: 10em; } select > option:checked::before { content: "SELECTED: "; } select > option:not(:checked)::before { content: "excluded: " ; } <select multiple> <option value="1" selected="selected">1</option> <option value="2"

create many DropDownListFor in foreach-loop [duplicate]

隐身守侯 提交于 2019-11-30 03:26:36
问题 This question already has answers here : DropDownListFor does not select value if in for loop (6 answers) How to set default value to select list in MVC during run time (2 answers) Closed 3 years ago . I want to create DropDownLists dynamically out of a List, which supplies the SelectList and a field where to save the selection. public class ViewModel { public List<Material_Select> materialSelect { get; set; } } public class Material_Select { public SelectList selectList { get; set; } public

How do I dynamically create an <option> in JavaScript that contains an HTML entity (— … «)?

自闭症网瘾萝莉.ら 提交于 2019-11-30 02:56:15
问题 I'd like to add an <option> element to a <select> element where the <option> element's text contains an HTML entity: — In HTML, the code would look like this: <select name="test" id="test"> <option value="">— Select One —</option> </select> My JavaScript code looks like this: function selectOne() { var e = document.getElementById('test'); e.options[0] = new Option('— Select One —', ''); } However, as you will see if you test this, the — becomes escaped. I had the same outcome when I tried: e

Laravel 4 blade drop-down list class attribute

℡╲_俬逩灬. 提交于 2019-11-30 02:52:44
Laravel blade drop down list class attribute not working. I cannot find any reference to class or assigning attributes to select / drop-down lists in the documentation. http://www.laravel.com/docs/html#drop-down-lists Examples tried: {{ Form::select('product_id', $productList, array('class'=>'form-control')) }} {{ Form::select('product_id', $productList, $attributes = array('class'=>'form-control')) }} Both return the same html but without the class attribute: <select id="product_id" name="product_id"> ... Option Stuff ... </select> {{ Form::select('product_id', $productList, null, array(

jQuery create select list options from JSON, not happening as advertised?

对着背影说爱祢 提交于 2019-11-30 02:48:26
问题 How come this doesn't work (operating on an empty select list <select id="requestTypes"></select> $(function() { $.getJSON("/RequestX/GetRequestTypes/", showRequestTypes); } ); function showRequestTypes(data, textStatus) { $.each(data, function() { var option = new Option(this.RequestTypeName, this.RequestTypeID); // Use Jquery to get select list element var dropdownList = $("#requestTypes"); if ($.browser.msie) { dropdownList.add(option); } else { dropdownList.add(option, null); } } ); } But