下面的代码用于从数据库中获取文件名。我收到了数据库的回复。我已经在脚本和列表中添加了html响应。
“responseText.exploded_filename [i]”是文件名。
当我点击“添加详细信息”按钮时。 Bootstrap模型将显示。
我的问题是当我为第二个文件名添加标题并单击“保存”时,警报将仅显示第一个文件名标题。
例如:对于“本地化”文件,我将标题编辑为类似“测试”的内容,然后单击保存警报显示第一页名称“参考”标题。
var i = 0;
if(responseText.success == true){
$(".filename").after('<a class="btn btn-sm btn-default download" href="" data-file="">'+responseText.exploded_filename[i]+'</a> <a href="" class="removeProcessEntryFile" style="color: #333; cursor: pointer;"><a href="" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModal_'+i+'" data-whatever="@mdo">Add Details</a></a><br><div class="modal fade" id="myModal_'+i+'" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"><div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="exampleModalLabel">Add File Details</h4> </div> <div class="modal-body"> <form action="" method="POST" name="formFileDetails_'+i+'" id="formFileDetails_'+i+'"> <div class="form-group"> <label for="recipient-name" class="control-label">Title</label> <input type="text" class="form-control" id="titleFileDetails" name="titleFileDetails" value="'+responseText.exploded_filename[i]+'"> </div> <div class="form-group"> <label for="message-text" class="control-label">Description</label> <textarea class="form-control" id="descriptionFileDetails" name="descriptionFileDetails"></textarea> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" id="saveFileDetails_'+i+'">Save</button> </div></form> </div></div> </div> </div>');
$("#saveFileDetails_"+i).on("click", function(e){
e.preventDefault();
var processEntryId = $("#entryID").val();
var titleFileDetails = $("#titleFileDetails").val();
var descriptionFileDetails = $("#descriptionFileDetails").val();
alert(titleFileDetails);
/* $.post("/customers/list/process/entries/file/details", {processEntryId: processEntryId, titleFileDetails: titleFileDetails, descriptionFileDetails: descriptionFileDetails}, function(response){
});*/
});
i++;