[問題] 關於createEleme input function onchange請教各位
----------------------------- 程式碼先 ---------------------------
<script language="JavaScript" type="text/javascript">
<!--
var num = 0;
function add_check(chk) {
if(eval('chk.form.myfile'+num+'.value.length')) {
if(num < 9) {
num++;
var new_inputfile = document.createElement("input");
new_inputfile.type = "file";
new_inputfile.name = "myfile" + num;
new_inputfile.onchange = "add_check(this)";
chk.form.appendChild(new_inputfile);
var s = document.createElement("br");
chk.form.appendChild(s);
}
}
}
function submitform() {
document.upload.submit();
}
-->
</script>
檔案上傳大小限制:1MB<br />
多檔上傳數量限制:10個
<form name="upload" action="fileupload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="max_file_size" value="1024000">
<input type="file" name="myfile0" onchange="add_check(this)"><br />
</form>
<a href="javascript: submitform()">上傳</a>
----------------------------- 程式結束 --------------------------
請問由createElement產生的input,
要如何加上onchange去呼叫function?
我感覺是這行錯誤
『new_inputfile.onchange = "add_check(this)";』
但又Google不到方法解決...就來求助看看吧 m(_*_)m
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.130.17.100
推
05/18 14:29, , 1F
05/18 14:29, 1F
→
05/18 14:39, , 2F
05/18 14:39, 2F
→
05/18 14:43, , 3F
05/18 14:43, 3F
→
05/18 14:44, , 4F
05/18 14:44, 4F
→
05/18 15:04, , 5F
05/18 15:04, 5F
→
05/18 19:37, , 6F
05/18 19:37, 6F
推
05/19 00:39, , 7F
05/19 00:39, 7F
推
05/19 04:16, , 8F
05/19 04:16, 8F
→
05/19 04:17, , 9F
05/19 04:17, 9F
→
05/19 23:31, , 10F
05/19 23:31, 10F
→
05/20 00:14, , 11F
05/20 00:14, 11F
推
05/20 08:39, , 12F
05/20 08:39, 12F
→
05/20 16:08, , 13F
05/20 16:08, 13F
→
05/20 16:22, , 14F
05/20 16:22, 14F
推
05/20 16:40, , 15F
05/20 16:40, 15F
推
05/20 16:41, , 16F
05/20 16:41, 16F
→
05/20 16:43, , 17F
05/20 16:43, 17F
→
05/20 16:43, , 18F
05/20 16:43, 18F
→
05/20 16:44, , 19F
05/20 16:44, 19F
→
05/20 16:45, , 20F
05/20 16:45, 20F
→
05/20 16:46, , 21F
05/20 16:46, 21F
→
05/20 16:47, , 22F
05/20 16:47, 22F
→
05/20 16:48, , 23F
05/20 16:48, 23F
→
05/20 16:49, , 24F
05/20 16:49, 24F
→
05/20 16:50, , 25F
05/20 16:50, 25F
→
05/20 16:58, , 26F
05/20 16:58, 26F
→
05/20 16:59, , 27F
05/20 16:59, 27F
→
05/20 16:59, , 28F
05/20 16:59, 28F
推
05/20 17:03, , 29F
05/20 17:03, 29F
→
05/20 17:04, , 30F
05/20 17:04, 30F
→
05/20 17:40, , 31F
05/20 17:40, 31F
→
05/20 19:08, , 32F
05/20 19:08, 32F
→
05/21 02:11, , 33F
05/21 02:11, 33F