日期:2014-05-16 浏览次数:20417 次
var i = 1;
function addFile() {
if (i < 8) {
var str = '<div><input type="file" name="File" runat="server" /> 描述:<input name="text" type="text" maxlength="20" /><input type="button" class="x" onclick="deleteFile(this)" value="X" /></div>';
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd", str);
i++;
}
else {
alert("您一次最多只能上传8张图片!");
}
}
function deleteFile(current) {
i--;
current.parentNode.parentNode.removeChild(current.parentNode);
}
<tr>
<td>
<span class="lblxian">请选择图片:</span>
</td>
<td>
<input id="File" type="file" runat="server" />
描述:<input id="img" name="text" type="text" maxlength="20" />
</td>
</tr>
<tr id="MyFile">
<td>
<input onclick="addFile()" type="button" value="增加图片(Add)" />
</td>
</tr>