`
eoasis
  • 浏览: 76756 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

让File控件的按钮更漂亮(原)

阅读更多

方法1:

让按钮变成好看的图片

<table border="0" cellspacing="0" cellpadding="0" class="px12gray_none_6e">
 <tbody>
 <tr>
 <td><input type="text" name="f_file" class="input_gray" size="20" disabled><input name="elmFile" type="file" style="position:absolute;filter:alpha(opacity=0); width: 20px; cursor: pointer;" id="elmFile" onchange="this.form.f_file.value=this.value" hidefocus></td>
 <td width="70" align="center"><img src="newsub_124.gif" width="47" height="18" style="cursor: pointer;" alt="浏览"></td>
 <td valign="bottom">(最大可能上传200K)</td>
 </tr>
 </tbody>
</table>

 

 

方法2:

改变按钮文字和颜色

<html>
<head>
<title>File Upload Example</title>
<script language="JavaScript" type="text/javascript">
function HandleFileButtonClick()
{
document.frmUpload.myFile.click();
document.frmUpload.txtFakeText.value = document.frmUpload.myFile.value;
}
</script>
</head>
<body>
<form name="frmUpload">
<input type="file" name="myFile" style="display: none">
<input type="text" name="txtFakeText" readonly="true">
<input type="button" onclick="HandleFileButtonClick();" value="上传文件" style="background:red">
</form>
</body>
</html>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics