Truly
写精彩代码 品暇逸人生

onmouseover="oldItemBackColor=this.style.backgroundColor;this.style.backgroundColor='#DEEFFF';" onmouseout="this.style.backgroundColor=oldItemBackColor;"

应用:datagrid的行变色
ItemCreated event

if(e.Item.ItemType != ListItemType.Header)
{
      e.Item.Attributes.Add("onmouseover", "oldItemBackColor=this.style.backgroundColor;this.style.backgroundColor='#DEEFFF';");
      e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=oldItemBackColor;");
}

根据value自动选择select的项

function searchSelectByValue(selectBox, searchValue) {
/** Searches a select combo box for the specified value; if found, it
 ** makes it the selected option
 ** truly
 **/
 var arOptions = selectBox.options;
 var strCompare = new String(searchValue).toLowerCase();
 var intCompareLen = strCompare.length;
 var i, j; // loop counters
 
 for (i = 0; i < arOptions.length; i++) {
  // did we match the search string?
  if (strCompare == arOptions[i].value.substring(0,
   intCompareLen).toLowerCase()) {  
   // remove all selections
   for(j = 0; j < arOptions.length; j++)
    selectBox.options[j].selected = false; 

   // select the option that matched and exit
   selectBox.options[i].selected = true
   break;
  }
 }
 
 if (i < arOptions.length)
  return(i); // return index of match when found
 else
  return(-1); // return -1 to indicate no match
}

// js对含有中文的字符串长度计算
function checkVal(s){
var k = 0
for(var i=0;i<s.length;i++){
if(s.charCodeAt(i) > 255){
k += 2
}
else{
k += 1
}
}
return k;
}


EnsureChildControls();

posted on 2006-04-12 16:32  Truly  阅读(540)  评论(0)    收藏  举报