html-select

How to Hide and Show SELECT Options with JQuery in IE

我的未来我决定 提交于 2019-12-01 16:27:05
I'm trying to hide some options from a drop down. JQuery's .hide() and .show() work great in Firefox and Chrome, but no luck in IE. Any good ideas? Of many possible approaches, this method requires browser sniffing (which in general is not great) but doesn't require having multiple copies of the same select list to swap in and out. //To hide elements $("select option").each(function(index, val){ if ($(this).is('option') && (!$(this).parent().is('span'))) $(this).wrap((navigator.appName == 'Microsoft Internet Explorer') ? '<span>' : null).hide(); }); //To show elements $("select option").each

Html.DropDownList default selected item

我的未来我决定 提交于 2019-12-01 16:12:20
问题 I am displaying a list of dropDownLists inside a ForEach loop. This is the code @foreach (var task in Model.TaskList) { <tr> <td>@Html.DropDownList("ModuleID", new SelectList(Model.ModuleList, "ModuleID", "Ordre")) </td> </tr> } I want the Module of each Task to be selected by default. This could easily be done using DropDownList if only I was binding the dropDownList to a view model, but that's not the case. Any ideas ? 回答1: This could easily be done using DropDownList if only I was binding

Positioning the drop down window of a HTML SELECT

六眼飞鱼酱① 提交于 2019-12-01 15:28:22
问题 I am using an HTML SELECT tag and want to make sure the window that opens when the user hits the arrow to position below the "textbox" part of the control. The problem is that IE seems to just open the window arbitrarily depending on the selection but I need to ensure consistent positioning as there are other elements on the page that need to remain visible at all times Here's the current markup <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"

How to fill dropdownlist for MVC4 razor views (C#)

笑着哭i 提交于 2019-12-01 09:57:44
问题 UserProfiles Model [Table("Users")] public class UserProfiles { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } //public string Password { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string MiddleName { get; set; } public string Initials { get; set; } public string Company { get; set; } public string Department { get; set; } public string Title { get; set

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

倾然丶 夕夏残阳落幕 提交于 2019-12-01 07:14:16
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 select multiple but he wants it this way. The user can add as many as these select boxes as they

IE10 Select box menu shows upside

十年热恋 提交于 2019-12-01 05:23:57
问题 I was testing my application in IE10 and found a strange behavior for select box. The option selected is highlighted and options above/below are displayed above/below the selected one. This happens only in IE10. <!DOCTYPE html> <html> <body> <select> <option value="One">One</option> <option value="Two">Two</option> <option value="Three">Three</option> <option value="Four">Four</option> </select> </body> </html> How to fix this?? Thanks in Advance. 回答1: This is the default behavior of select

HTML select shows value instead of text

安稳与你 提交于 2019-12-01 03:45:20
Is it possible in a html select , to display the value of the option instead of the text? It's gonna be used for displaying a long disription in the dropdown, but when selecting it should only be showing a short text/ the value of the option. code: <select> <option value="1">This is a long long text, that explains option 1</option> <option value="2">This is a long long text, that explains option 2</option> </select> Now the selected item, when you leave the dropdown/combobox/whatever, should only display '1' You can do it by using the label tag: <option value="the_value" label="the text

Setting a default selected value in DropDownList in MVC3

本小妞迷上赌 提交于 2019-12-01 03:25:26
In MVC3 I have this code at my controller. It retrieves a List of IDs\Names from Installation table and creates a ViewBag var vs = dba.Installation.OrderBy(q => q.InstName).ToList(); ViewBag.Vessels = new SelectList(vs, "InstId", "InstName"); Now, at my view. I want to render the list in a dropdown list. I used the Html helper that works fine... @Html.DropDownList("InstId",(SelectList)ViewBag.Vessels, "- Select one -") I need to set first item in the ViewBag List as a default selected value, instead of "- Select one -" text. How can I do it? Thanks in advance! There's an overload for the

Setting a default selected value in DropDownList in MVC3

拟墨画扇 提交于 2019-11-30 23:39:17
问题 In MVC3 I have this code at my controller. It retrieves a List of IDs\Names from Installation table and creates a ViewBag var vs = dba.Installation.OrderBy(q => q.InstName).ToList(); ViewBag.Vessels = new SelectList(vs, "InstId", "InstName"); Now, at my view. I want to render the list in a dropdown list. I used the Html helper that works fine... @Html.DropDownList("InstId",(SelectList)ViewBag.Vessels, "- Select one -") I need to set first item in the ViewBag List as a default selected value,

System.Data.DataRowView in DropDownList

試著忘記壹切 提交于 2019-11-30 23:18:11
I am trying to populate a dropdown using values from a column. Now the problem is: I am not getting the actual values (the country codes like India(+61)) in the dropdown. Instead I am getting "System.Data.DataRowView" (multiple times) in the dropdown. public void bind() { DataSet ds1 = new DataSet(); SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]); con.Open(); string strQuery = "select CountryCode from AUser"; SqlCommand cmd = new SqlCommand(strQuery, con); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) da.Fill(ds1, "AUser")