<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 7</title>
<script>
function test() {
with(document.frm1) {
F1.click();
FileName.value = F1.value;
}
}
</script>
</head>
<body>
<form name="frm1" method="POST" enctype="multipart/form-data">
<input type="file" id="F1" name="F1" size="20" style="display:none">
<input type="text" name="FileName" size="20">
<input type="button" value="TEST" name="B1" onclick="test()">
</form>
</body>
</html>
此博客展示了一段HTML代码,通过JavaScript函数实现文件选择功能。代码中隐藏了文件输入框,点击按钮触发函数,使文件输入框被点击并将所选文件名显示在文本框中,涉及HTML标签和JavaScript函数的运用。

805

被折叠的 条评论
为什么被折叠?



