Javascript 关于文本框中未显示的多文件输入和路径丢失
我使用JavaScript在一个表单中添加多个表单,当我将路径文件添加到重复表单的fileinput时,会出现一个问题,即不会显示其路径 这是javascript thorugh,我正在复制表单Javascript 关于文本框中未显示的多文件输入和路径丢失,javascript,php,jquery,html,forms,Javascript,Php,Jquery,Html,Forms,我使用JavaScript在一个表单中添加多个表单,当我将路径文件添加到重复表单的fileinput时,会出现一个问题,即不会显示其路径 这是javascript thorugh,我正在复制表单 var count=0; $(document).on("click", "#addanother", function(){ count=count+1; $(".content #formImage:last").append('<br>'); divco
var count=0;
$(document).on("click", "#addanother", function(){
count=count+1;
$(".content #formImage:last").append('<br>');
divcontent='<form id="formImage'+count+'" name="formImage[]">'+
'<input type="hidden" id="api'+count+'" name="api" value="addImageInPack" />'+
'<input type="hidden" id="imageusername'+count+'" name="username" value="" />'+
'<input type="hidden" id="imagepassword'+count+'" name="password" value="" />'+
'<table width="100%" style="border:2px solid #ffffffl;" id="multipleImages'+count+'" >'+
'<tbody>'+
'<tr><td><label for="imagetitle">Title (Optional)</label></td>'+
'<td><span id="remove" style="cursor:pointer;"><img src="img/cross.png" width="10px" style="float: right; right:0;" /></span><br />'+
'<input type="text" id="imagetitle'+count+'" name="title[]" style="width:100%" /></td>'+
'</tr>'+
'<tr>'+
'<td><label for="imagetags" style="width:100%">Tags</label></td>'+
'<td><input type="text" id="imagetags'+count+'" name="tags[]" style="width:100%" /></td>'+
'</tr>'+
'<tr>'+
'<td><label for="imagedescription" style="width:100%">Description (Optional)</label></td>'+
'<td><textarea id="imagedescription'+count+'" name="description[]" style="width:100%"></textarea></td>'+
'</tr>'+
'<tr>'+
'<td><label for="imagepackid" style="width:100%">Pack</label></td>'+
'<td><select id="imagepackid'+count+'" name="packid[]" style="width:100%">'+"'<?php echo $server->getPackOptions() ?>+'"+'</select></td>'+
'</tr>'+
'<tr>'+
'<td><label for="file">Image:</label></td>'+
'<td>'+
'<input class="file" style="display: inline; width: 150px;">'+
'<div class="file-btn" style="width: 85px; height: 28px; display: inline; position: absolute; overflow: hidden; cursor: pointer; background-position: 100% 50%;">'+
'<input type="file" name="file" id="image" style="position: relative; height: 28px; width: 150px; display: inline; cursor: pointer; opacity: 0; margin-left: -65px;">'+
'</div>'+
'<img src="img/uploadIcon.png" width="20px">'+
'</td>'+
'</tr>'+
'</tbody>'+
'</table>'+
'</form>';
jQuery('.content #formImage').append(divcontent);
});
var计数=0;
$(文档)。在(“单击”,“添加另一个”,函数()上){
计数=计数+1;
$(“.content#formImage:last”).append(“
”);
divcontent=''+
''+
''+
''+
''+
''+
'标题(可选)'+
“
”+
''+
''+
''+
“标签”+
''+
''+
''+
'说明(可选)'+
''+
''+
''+
“打包”+
''+"'+'"+''+
''+
''+
'图像:'+
''+
''+
''+
''+
''+
''+
''+
''+
''+
''+
'';
jQuery('.content#formImage').append(divcontent);
});
这是原始html代码:
<form id="formImage" name="formImage[]">
<input type="hidden" id="api" name="api" value="addImageInPack" />
<input type="hidden" id="imageusername" name="username" value="" />
<input type="hidden" id="imagepassword" name="password" value="" />
<table width="100%" style="border:2px solid #ffffffl;" id="multipleImages" >
<tbody>
<tr>
<td><label for="imagetitle">Title (Optional)</label></td>
<td>
<span id="remove" style="cursor:pointer;"><img src='img/cross.png' width='10px' style="float: right; right:0;" /></span>
<br />
<input type="text" id="imagetitle" name="title[]" style="width:100%" /></td>
</tr>
<tr>
<td><label for="imagetags" style="width:100%">Tags</label></td>
<td><input type="text" id="imagetags" name="tags[]" style="width:100%" /></td>
</tr>
<tr>
<td><label for="imagedescription" style="width:100%">Description (Optional)</label></td>
<td><textarea id="imagedescription" name="description[]" style="width:100%"></textarea></td>
</tr>
<tr>
<td><label for="imagepackid" style="width:100%">Pack</label></td>
<td><select id="imagepackid" name="packid[]" style="width:100%"><?php echo $server->getPackOptions() ?></select></td>
</tr>
<tr>
<td><label for="file">Image:</label></td>
<td>
<input type="file" name="file[]" id="image"/>
<img src="img/uploadIcon.png" width="20px"/>
</td>
</tr>
</tbody>
</table>
</form>
标题(可选)
标签
说明(可选)
包裹
图片:
问题如前所述,在上传图像时,第二个输入文件路径未显示
第二个问题是我想通过javascript删除这个动态创建的表单。如何做到这一点。感谢您提前提供帮助。您看不出我已经使用count变量更改了元素的id。我不应该删除我的注释。真的吗<代码>