Created
November 5, 2012 09:00
-
-
Save binjoo/4016127 to your computer and use it in GitHub Desktop.
JAVASCRIPT:从EXECL中拷贝多行数据,粘贴至HTML INPUT控件中。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 从EXECL中拷贝多行数据,粘贴至HTML INPUT控件中。 | |
* event 用户键盘操作对象 | |
* obj 被粘贴的控件对象 | |
* num 第几行 | |
**/ | |
function copyValue(event, obj ,num){ | |
if (event != null && event.ctrlKey && event.keyCode == 86) { | |
var text = window.clipboardData.getData("Text"); | |
var input = document.getElementsByName(obj.name); | |
if(text.indexOf("\r\n") != -1){ | |
event.keyCode = 0; | |
var sheetrows = text.split("\r\n"); | |
for(var i=num-1,j=0; i<input.length; i++,j++){ | |
if(typeof(sheetrows[j]) != 'undefined' && typeof(input[i]) != 'undefined'){ | |
input[i].value = sheetrows[j]; | |
}else{ | |
return false; | |
} | |
} | |
}else{ | |
obj.value = text; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment