Js for Select

來源:互聯網
上載者:User


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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.