我通過javascript製作了一個輸入文件類型。我看不到輸入文件類型中的瀏覽按鈕
輸入類型文件生成如我所料,除了我看不到瀏覽按鈕。
我搜索輸入文件類型的CSS樣式,但我看到的是如何定製
瀏覽器按鈕。以下是我的屏幕外觀。
通常,文件類型應該表現爲第二個,但我得到第一個,當我
產生的JavaScript文件類型。下面是我的代碼。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
.uploadForm{
type:file; position:relative;
}
#addBtn{
width:100px; height:20px;
}
</style>
<script>
function addMoreFiles(){
var fileForm = document.createElement('input');
var addButton = document.createElement('button');
addButton.setAttribute('onclick', "addMoreFiles()");
addButton.setAttribute('id', "addBtn");
fileForm.className = 'uploadForm';
document.getElementById('uploadDiv').appendChild(fileForm);
document.getElementById('uploadDiv').appendChild(addButton);
}
</script>
</head>
<body onload="addMoreFiles()">
<form name="frmname" method="post" enctype="multipart/form-data" action="./ViewPage.jsp">
file<br>
<div id="uploadDiv"></div>
<br>
<input type="file" name="uploadFile"><br>
<input type="submit" value="upload"><br>
</form>
</body>
</html>
有人可以告訴我我做錯了什麼嗎?提前致謝。
你能告訴我們完整的代碼嗎? – 11684 2012-04-19 06:41:42
我現在更新了我的代碼 – 2012-04-19 06:47:04