我正在创建一个简单的Web应用程序,用户可以使用该应用程序编写带有附加文件的消息.
多个html文件输入与javascript链接http://img38.imageshack.us/img38/4474/attachments.gif
"附加其他文件"链接尚不起作用.它应该在每次单击时向表单添加一个额外的文件输入控件.
我需要一个JavaScript方法addanotherfileinput()来替换单击的锚点:
<a href="#" id="attachlink" onclick="addanotherfileinput">attach additional files</a>
Run Code Online (Sandbox Code Playgroud)
使用此新表行,文件输入和锚点:
<input type="file" name="Attachment1" id="Attachment1" class="textinput" />
</td>
</tr>
<tr>
<td></td>
<td>
<a href="#" id="attachlink" onclick="addanotherfileinput">attach additional files</a>
Run Code Online (Sandbox Code Playgroud)
并且还增加了数字:附件2,附件3,附件4等.
我怎样才能做到这一点?
您可以使用DOM动态插入文件输入
var myTd = /* Get the td from the dom */
var myFile = document.createElement('INPUT');
myFile.type = 'file'
myFile.name = 'files' + i; // i is a var stored somewhere
i++;
myTd.appendChild(myFile);
Run Code Online (Sandbox Code Playgroud)
或者你可以使用它
http://developer.yahoo.com/yui/examples/uploader/uploader-simple-button.html
| 归档时间: |
|
| 查看次数: |
211 次 |
| 最近记录: |