关于问题

zhanggc1001 2008-04-07 11:42:20
<html>
<head>
</head>
<body>
<input type=file id="file1"/><br>
<input type=file id="file2"/><br>
<input type=button value="submit" onclick="test()"/>
</body>
</html>
我想在id=“file2”选择完上传文件后把值显示在id=“file1”的里面去
同时id=“file2”显示为空
怎么做啊,用value去赋值不起作用啊!!
...全文
170 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2008-04-07
  • 打赏
  • 举报
回复
安全问题,file字段不能赋值。在本机应用可以,htm改成hta。
muxrwc 2008-04-07
  • 打赏
  • 举报
回复
可以模拟一个file
就是
左边是input[text]
右边是input[file]
然后右边的z-index比左边的小。
margin:负值
这样
右边的file
的文本部分就被左边的text给盖住了。
muxrwc 2008-04-07
  • 打赏
  • 举报
回复
大概是这样的...
不过,你要是想给file加默认值是不可能的..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<div style="position:relative;">
<input id="wc" type="text" name="file" style="position:relative;z-index:2; background-color:#CCCCCC;" />
<input type="file" style="position:absolute;z-index:1;left:0;" onchange="document.getElementById('wc').value = this.value" />
</div>
</body>
</html>

仔细看了下你的需求,貌似,只是把file1和file2换下位置那么简单 - -
Go 旅城通票 2008-04-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 hookee 的回复:]
安全问题,file字段不能赋值。在本机应用可以,htm改成hta。
[/Quote]


就算用div模拟了,你提交时也不能获得file1的值(为空),除非你重新选择过file1
zhanggc1001 2008-04-07
  • 打赏
  • 举报
回复
有没有人知道1楼模拟的具体方法啊,在线等!
zhanggc1001 2008-04-07
  • 打赏
  • 举报
回复
1楼的能不能说的在清楚些呢?

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧