html-select

How to set the 'selected option' of a select dropdown list with jquery

五迷三道 提交于 2019-12-03 03:38:25
问题 I have the following jquery function: $.post('GetSalesRepfromCustomer', { data: selectedObj.value }, function (result) { alert(result[0]); $('select[name^="salesrep"]').val(result[0]); }); result[0] is a value that I want to set as the selected item in my select box. result[0] equals Bruce jones . the select box is populated by a database query but one of the rendered html is: <select id="salesrep" data-theme="a" data-mini="true" name="salesrep"> <option value=""> </option> <option value=

How to style asp.net dropdownlist

£可爱£侵袭症+ 提交于 2019-12-03 03:16:48
You may feel it is a repeated question, but I have a Asp:DropDownList which needs to be styled like the below picture. I browsed through Google and some sites (mentioned in Stack), but I couldn't get the expected outcome. Can anybody help me in this? Thanks in advance.. Try the following code HTML <asp:DropDownList ID="DropDownList1" runat="server" Width="120px" BackColor="#F6F1DB" ForeColor="#7d6754" Font-Names="Andalus" CssClass="ddl"> <asp:ListItem Text="DEPART FROM"></asp:ListItem> </asp:DropDownList> CSS EDIT <style type="text/css"> .ddl { border:2px solid #7d6754; border-radius:5px;

Prevent iPhone from zooming form?

心不动则不痛 提交于 2019-12-03 00:47:39
问题 The code: <select> <option value="1">Home</option> <option value="2">About</option> <option value="3">Services</option> <option value="4">Contact</option> </select> When I touch select , the iPhone zooms in that element (and does not zoom out after deselecting). How can I prevent this? Or zoom back out? I can't use user-scalable=no because I actually need that functionality. It's for iPhone, select menu. 回答1: UPDATE : This method no longer works on iOS 10. It depend from the Viewport, you can

<SELECT multiple> - how to allow only one item selected?

霸气de小男生 提交于 2019-12-03 00:31:24
问题 I have a <SELECT multiple> field with multiple options and I want to allow it to have only one option selected at the same time but user can hold CTRL key and select more items at once. Is there any way how to do it? (I don't want to remove 'multiple'). 回答1: Just don't make it a select multiple, but set a size to it, such as: <select name="user" id="userID" size="3"> <option>John</option> <option>Paul</option> <option>Ringo</option> <option>George</option> </select> Working example: https:/

How to get select box option value in jQuery

三世轮回 提交于 2019-12-02 21:03:01
How to get the value of option select box in jQuery if I have the code like this, <select id='media' name='media'> <option value='1'>media1</option> <option value='2'>media2</option> <option value='3'>media3</option> </select> When I code for on change event, $(document).ready(function() { $("#media").change(function() { var id=$(this).val(); var dataString = 'id='+ id; alert(id); return false; }); }); It gives me media1 , media2 , media3 instead of 1, 2, 3 How to get the value 1, 2, 3? SureshKumaran $("#id option:selected").val(); Here id is the id of a select box. I'm sure it will work 100%.

How to solve the select overlap bug in IE6?

廉价感情. 提交于 2019-12-02 20:22:03
When using IE, you cannot put an absolutely positioned div over a select input element. That's because the select element is considered an ActiveX object and is on top of every HTML element in the page. I already saw people hiding selects when opening a popup div, that leads to pretty bad user experience having controls disappearing. FogBugz actually had a pretty smart solution (before v6) of turning every select into text boxes when a popup was displayed. This solved the bug and tricked the user eye but the behavior was not perfect. Another solution is in FogBugz 6 where they no more use the

jQuery Set Selected Option Using Next

守給你的承諾、 提交于 2019-12-02 19:01:42
How can I, using jQuery, set the "next" item of an already selected item as "selected." For example, if I have: <select> <option value="1" >Number 1</option> <option value="2" selected="selected">Number 2</option> <option value="3" >Number 3</option> <option value="4" >Number 4</option> </select> We can see that "Number 2" is selected, and using jQuery, I'd like to set "Number 3" as selected, and remove the selected "attribute" from "Number 2". I'm assuming I need to use the next selector, but I'm not quite sure how to implement. $('option:selected', 'select').removeAttr('selected').next(

Rails 3: f.select - options_for_select

前提是你 提交于 2019-12-02 17:29:27
I have a form on my Ruby on Rails3 Application with a drop menu, this is my current code for the select option: <%= f.select :phone_type, options_for_select(["Select One", "Cell", "Work", "Office", "Home", "Other"],:disabled => ["Select One"]), :class => 'genForm_dropBox' %> From my understanding this should have "Select One" as the default option when someone opens the page, but if they don't select one of the other options an error displays when they hit submit. This is true in Browsers like Safari and Chrome and IE7, but in Firefox and IE8 it shows "Cell" as the first option as Select One

Getting error when using post method in form

本小妞迷上赌 提交于 2019-12-02 17:26:39
问题 I am getting null when I am using post method while passing a form to the next page A repeat of this question link text <html> <head> Title <script> function callme() { alert("Hi"); alert(document.getElementById("prio").value); } </script> </head> <body> <FORM method="post" name="test"enctype="multipart/form-data" action="testjsp.jsp" > <select name="prio" id="prio"> <option>1</option> <option>2</option> </select> <input type="submit" value="Submit" onClick=callme();> </form> </body> </html>

Formatting dates in an MVC Dropdown

与世无争的帅哥 提交于 2019-12-02 17:21:20
问题 I have a dropdown list on my page as so: - @Html.DropDownList("dd_dates", new SelectList(@Model.seasonDates), "Please Select") where seasonDates is an IList of dates. The problem is that when the dates are displayed in the dropdown they also have the time on them as well. How do I format the display date so that the time is not included. 回答1: Maybe a better way to do this would be to define a property in your model that returns IEnumerable<SelectListItem> (in your model class): public