1)var obj;
obj = document.getElementById("Card"); //擷取標籤的Id
index = obj.selectedIndex; // 選中索引
value = obj.options[index].value; // 選中value值
text = obj.options[index].text; // 選中text值
2)增加新一行
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(); //清空資料
4)省、市、區的聯動,選擇預設值
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)動態給table添加新一行的資料
function insertRow2(MaterialCode,MaterialName,Weight,UnitName,RetailPrice,InvQty,i){
var lb1Name="lbName"+i; //貨品全稱
var lb1Price="lbPrice"+i;//價格
var lbWeight="lbWeight"+i; //規格
var lbInvQty="lbInvQty"+i; //庫存量
$("#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+'元</label>)</td>'+
'<td width=100>備貨量:<label id='+lbInvQty+'>'+InvQty+'</label></td>'+
"</tr>");
}
作者:loveheronly