function Loadsteel_num (typeid) {
var Drp2 = $ ("Drsteel_num");
drp2.options.length=0;
DownloadURL (' bsorder_steel_num.asp tutorial x?b_typeid= ' +typeid, function (XML, Responsecode) {
var dom
if (document.all)//ie
{
Dom=new ActiveXObject ("Microsoft.XMLDOM");
Dom.loadxml (XML)
}
else if (window.domparser)//firefox
Dom=new Domparser (). parsefromstring (XML, "Text/xml");
if (DOM)
{
ITEMS1 = Dom.getelementsbytagname ("item");
var itemslength=items1.length;
for (I=0;i <itemslength;i++)
{
var newoption = document.createelement ("option");
Newoption.text=items1[i].getattribute ("name");
Newoption.value= Items1[i].getattribute ("name");
Drp2.options.add (newoption);
}
}
});
<items>
<item name= "ABC" ></item>
</items>
Method Two
$ ("#selectid"). Append ("<option value= '" +value+ "' >" +text+ "</option>");
Of course, in addition to this sentence, there are set the default selection value, the first value, the last value, the nth value and so on, so search on the Internet:
jquery Gets the text and value selected by select:
1. $ ("#select_id"). Change (function () {//code ...}); Adds an event for a select that fires when one of the items is selected
2. Var checktext=$ ("#select_id"). Find ("option:selected"). Text (); Gets the text selected by select
3. Var checkvalue=$ ("#select_id"). Val (); Gets the value of the Select selection
4. Var checkindex=$ ("#select_id"). Get (0). SelectedIndex; Get the index value selected by select
5. Var maxindex=$ ("#select_id option:last"). attr ("index"); Get the maximum index value for select
jquery Add/Remove option items for select:
1. $ ("#select_id"). Append ("<option value= ' value ' >text</option>"); Append an option to select (dropdown)
2. $ ("#select_id"). Prepend ("<option value= ' 0 ' > Please select </option>"); Inserts an option for the Select (first position)
3. $ ("#select_id option:last"). Remove (); Delete index value maximum option (last) in select
4. $ ("#select_id option[index= ' 0 ']"). Remove (); Delete option with index value of 0 in select (first)
5. $ ("#select_id option[value= ' 3 ']"). Remove (); Delete option value= ' 3 ' in select
5. $ ("#select_id option[text= ' 4 ']"). Remove (); Delete option text= ' 4 ' in select
jquery Dynamic Add Option method four
First validation
$ (document). Ready (function () {
$ ("#listone"). DblClick (function () {
Alert ($ ("#listone option:selected"). Text ();//The text and HTML here have the same result.
var temp = $ ("#listone option:selected"). Text ();
$ ("<div>"). HTML (temp). Appendto ("... "); $ ("<div>") or $ ("<span>") can be dynamically added
Try $ ("<option>"). HTML (temp). Appendto ("#listtwo"); Failed!!!
The last change is $ ("option"). HTML (temp). Appendto ("#listtwo"); it's not yet known why Hope Master give answer
$ ("#listone option:selected"). Appendto ("#listtwo");
});
});
<div>
<select size= "Ten" class= "MyText" id= "Listone"
<option>1</option>
<option>3</option>
< Option>4</option>
<option>5</option>
</select>
<div id= " Title "> Add </div>
<select size=" Ten "class=" MyText "id=" Listtwo "
</select>
<div id= "Auto" ></DIV>
</div>
CSS Tutorial
<pre class=java name= "code" ><style type= "Text/css"
<!--
. mytext {
width:200px;
height:200px;
background-color: #ffffff;
clear:right;
float:left;
}
#title {
clear:right
float:left;
padding-top:80px;
&NBSP;WIDTH:70PX;
text-align:center;
}
</style>
</pre>
<br>