html-select

How to input text in HTML Select Tag?

亡梦爱人 提交于 2019-11-29 02:37:32
I want to make input option in select tag so user can choose between options or insert different value. Is it possible? <select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> **<insert user value>** </select> HTML solution with "list" attribute: <input type="text" name="city" list="citynames"> <datalist id="citynames"> <option value="Boston"> <option value="Cambridge"> </datalist> Fencer04 You will have to use javascript to get the additional value. Check this post for some example code:

Razor DropDownListFor: Adding Extra Attribute To SelectList Option Tag

梦想与她 提交于 2019-11-29 02:37:00
I'm trying to create a select list. I've created it just fine using a collection from my viewmodel that allows me to set each option's value and text with the following code: @Html.DropDownListFor(model => model.Networks, new SelectList(Model.Networks, "NetworkID", "Name"), new { @class="form-control" }) Model.Networks contains another property called CountryId. I'd like to add an attribute to each option tag so it looks like: <option value="[NetworkId]" data-countryId="[CountryId]">Canada</option> Which way should I go about doing this? You can create a Form Helper class to create a custom

Angularjs ngOption with array

佐手、 提交于 2019-11-29 01:14:42
I want to add an html select with options AM,PM with angularjs, what i need is having the key and the value of the option be the same : <option value="AM">AM</option> <option value="PM">PM</option> My html looks like this <select ng-model="ampm" ng-options="k as v for (k , v) in ampms"></select> and my controller looks like $scope.ampm = (new Date().getHours()) >= 12 ? 'PM' : 'AM'; $scope.ampms ={"AM":"AM","PM":"PM"}; and every thing working fine. My question is why i cant have the same thing when i used an array (i tried all the options in the ng-options) as this $scope.ampms =["AM","PM"];

dropdownlist styling in Internet explorer [duplicate]

时光毁灭记忆、已成空白 提交于 2019-11-29 00:43:27
This question already has an answer here: IE10 Select box issue 4 answers I have some problems with the way IE renders my DropDownList. In Firefox it looks as it should and thats the way I wanted displayed in IE too. Here is a screenshot of the dropdownlist in Firefox: screenshot in IE: I want the dropdown to expand vertically up until where the dropdownlist is, I don't want the dropdown to go below the existing dropdown control. Is there some trick how to do that with css? Thanks in advance, Laziale Michael Liu This is just the way that drop-down menus work in Internet Explorer 10 and up (as

Laravel 4 blade drop-down list class attribute

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 23:47:14
问题 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=

ASP.NET MVC 4 ViewModel with DropDownList data

百般思念 提交于 2019-11-28 21:41:45
I'm using @html.EditorFor to render my model in edit mode, and a dropdownlist is not rendered. Here's my ViewModel: public class RiskAutoViewModel { public RiskAutoViewModel() { VehicleMakeList = new SelectList(new List<VehicleMake>() { new VehicleMake() { Id = 1, Name = "Renault" }, new VehicleMake() { Id = 2, Name = "Peugeot" } }); } public int NoClaimsDegree { get; set; } public int VehicleValue { get; set; } public int EngineCapacity { get; set; } public int VehicleMake { get; set; } public SelectList VehicleMakeList { get; set; } } VehicleMake is rendered as a textbox and VehicleMakeList

Include blank for first item in select list in options_for_select tag

假如想象 提交于 2019-11-28 21:00:20
I tried :include_blank => true , but it didn't work. <select> <%= options_for_select Model.all.collect{|mt| [mt.name, mt.id]} %> </select> If I need to add it to the collection, how would you do that? I think you want this format: select("model_name", "model_id", Model.all.collect {|mt| [ mt.name, mt.id ] }, {:include_blank => 'name of your blank prompt'}) BTW: was assuming Modle was suppose to be Model. To use using collection_select: collection_select(:model, :model_id, Model.all, :id, :name, :prompt => true) I believe the :include_blank options only exist for select fields tied to a model.

Post values from a multiple select

大兔子大兔子 提交于 2019-11-28 19:04:04
How can I post values from a multiple select in a form? When I hit submit none of the selected values are posted. <form id="form" action="" method="post"> <div> <select id="inscompSelected" multiple="multiple" class="lstSelected"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <input type="submit" value="submit"> </div> </form> iambriansreed You need to add a name attribute. Since this is a multiple select, at the HTTP level, the client just sends multiple name/value pairs with the same name, you can observe this

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

纵然是瞬间 提交于 2019-11-28 17:10:13
How do you get the currently selected <option> of a <select> element via JavaScript? This will do it for you: var yourSelect = document.getElementById( "your-select-id" ); alert( yourSelect.options[ yourSelect.selectedIndex ].value ) Amber The .selectedIndex of the select object has an index; you can use that to index into the .options array. Ir Calif var payeeCountry = document.getElementById( "payeeCountry" ); alert( payeeCountry.options[ yourSelect.selectedIndex ].value ); Using the selectedOptions property: var yourSelect = document.getElementById("your-select-id"); alert(yourSelect

Make some options in a select menu “unselectable”

戏子无情 提交于 2019-11-28 16:38:38
I have a select element with a few options, but I want some of the options to not be selectable. Basically it's like this: <select> <option> CITY 1 </option> <option> City 1 branch A </option> <option> City 1 branch B </option> <option> City 1 branch C </option> <option> CITY 2 </option> <option> City 2 branch A </option> <option> City 2 branch B </option> ... </select> So as you can see, I don't want the cities do be directly selectable, but only the options that come under each city. How can it be done that the user can click on CITY 1 or CITY 2 but it won't be selected, so the user is