Contact the front end also soon for jquery with just fur, write the past feel can be re-use of the issue, we pointed out
1. Dynamic assignment of drop-down lists
functionvarnew Date (); var startyear = Mydate.getfullyear ()-var endyear = mydate.getfullyear () + for (var i = startyear; i < endyear; i++) {jQuery ("#ddlYear"). Append ("<option value=" + i + ">" + i + "</option>"var count = $ ("#ddlYear"). Size (); $ (' #ddlYear ') [0].selectedindex = Wuyi;}
Year:<asp:dropdownlist id="ddlyear" runat="server " Width="> <asp:listitem value="0" >--Please select--</asp:listitem>
2. Get the value of the drop-down list
- Gets the text selected by the Select:
$ ("#ddlregtype"). Find ("option:selected"). Text ();
- Gets the value selected by select:
$ ("#ddlregtype"). Val ();
- Gets the index selected by the select:
$ ("#ddlregtype"). Get (0). SelectedIndex;
Set Select:
- Set the index selected by select:
$ ("#ddlregtype"). Get (0). Selectedindex=index;//index as index value
Set the value selected by select:
$ ("#ddlregtype"). attr ("value", "normal"); $ ("#ddlregtype"). Val ("normal"); $ ("#ddlregtype"). Get (0). value = value;
Set the text selected by select:
var count=$ ("#ddlregtype option"). Length; for (Var i=0;i<count;i++) { if ($ ("#ddlregtype"). Get (0). Options[i].text = = text) { $ ("# Ddlregtype "). Get (0). options[i].selected = true; break; } } $ ("#select_id option[text= ' jquery ']"). attr ("selected", true);
To set the Select option entry:
$ ("#select_id"). Append ("<option value= ' value ' >text</option>"); Add an option $ ("#select_id"). Prepend ("<option value= ' 0 ' > Please select </option>");//Insert an option $ ( "#select_id option:last"). Remove (); Delete the maximum index value of option $ ("#select_id option[index= ' 0 ']"). Remove ();//delete the option $ ("#select_id option[) with the index value of 0 Value= ' 3 ']. Remove (); Delete option $ ("#select_id option[text= ' 4") with a value of 3. Remove ();//delete option with text value 4
Clear Select:
$ ("#ddlregtype"). empty ();
Work requires that you want to get the values from two forms.
How do I get the value from the left selection box to the right selection box? I think I want to use the web effects can be obtained, here with the more popular jquery.
The JS code is as follows:
Get all property values var item = $ ("#select1"). Val (); $ (function () { $ (' #select1 '). each ( //) gets all values for the Select1 function () { $ (' button '). Click (function () { Alert ($ (' #select2 '). Val ()); Get Select1 value in Select2});})
jquery dynamically assigns and takes values to the drop-down list and takes the index