一些常用的js代码(更新中)
2006-04-12 16:32
309 查看
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();
应用: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();
相关文章推荐
- 放一些常用的链接(不断更新)
- 常用的一些函数(未完结,持续更新)
- C++的一些常用知识(持续更新)
- dba一些常用的管理语句(不断更新)
- 我所接触到的一些常用Linux命令和用法(初学者献丑了)每日更新.......
- 一些常用的linux命令,陆续更新中...
- 一些常用数据结构的数组实现 不定期更新
- VIM一些设置及常用shell命令总结(不断更新...)
- .NET一些常用的语句集合(不断更新中)
- 一些常用的集合工具的代码块(缓慢更新XD)
- .NET中的一些常用资料总结和收集(不断更新)
- 一些前端真正常用的工具和网站(会经常更新)
- Oracle一些常用的查询命令总结(持续更新)
- 开发中常用的工具类、通用 UI 的集合,目前在不断的更新中,尽可能的覆盖 Android 开发中通用的一些东西
- 积累一些不太常用的C/C++语言知识(不断更新)
- npm 一些常用命令总结,不定期更新
- 常用的一些liunx命令(不断更新中)
- VBS一些常用函数-持续更新
- kafka一些常用命令(持续更新)
- 一些常用的JS功能函数(一) (2009-06-04更新)