1) var obj;
Obj = document. getElementById ("Card"); // obtain the tag Id
Index = obj. selectedIndex; // select an index
Value = obj. options [index]. value; // select the value.
Text = obj. options [index]. text; // select the text value.
2) Add a new row
AddSelectEmptyAndValueOption (obj, value, text );
Function addSelectEmptyAndValueOption (select, value, value2 ){
Var option = document. createElement ("option ");
Option. value = value;
Option. innerHTML = value2;
Select. appendChild (option );
}
3) $ ('# selectid'). empty (); // clear data
4) Select the default value for province, city, and district linkages
Function refreshResult (s ){
Var obj;
Var str;
Var I;
If (s = "1 "){
Obj = document. getElementById ("province ");
Str = '<% = deliveryprovince %> ';
For (I = 0; I <obj. length; I ++ ){
If (obj [I]. text = str ){
Obj [I]. selected = true;
ShowAreaInfo (obj [I]. value, "city ");
RefreshResult ("2 ");
}
}
} Else if (s = "2 "){
Obj = document. getElementById ("city ");
Str = '<% = deliverycity %> ';
For (I = 0; I <obj. length; I ++ ){
If (obj [I]. text = str ){
Obj [I]. selected = true;
ShowAreaInfo (obj [I]. value, "county ");
RefreshResult ("3 ");
}
}
} Else if (s = "3 "){
Obj = document. getElementById ("county ");
Str = '<% = deliveryarea %> ';
For (I = 0; I <obj. length; I ++ ){
If (obj [I]. text = str ){
Obj [I]. selected = true;
}
}
}
}
5) dynamically Add a new row of data to the table
Function insertRow2 (MaterialCode, MaterialName, Weight, UnitName, RetailPrice, InvQty, I ){
Var lb1Name = "lbName" + I; // full name of the product
Var lb1Price = "lbPrice" + I; // price
Var lbWeight = "lbWeight" + I; // Specification
Var lbInvQty = "lbInvQty" + I; // inventory
$ ("# ShopInvInfo"). append ("<tr>" +
'<Td width = 100> <label id =' + lb1Name + '>' + MaterialName + '</label> </td>' +
'<Td width = 100> (<label id =' + lbWeight + '>' + Weight + ''+ UnitName + '</label>) </td>' +
'<Td width = 100> (<label id =' + lb1Price + '>' + RetailPrice + 'RMB </label>) </td>' +
'<Td width = 100> stock preparation: <label id =' + lbInvQty + '>' + InvQty + '</label> </td>' +
"</Tr> ");
}
Author: loveheronly