var counter = 0;
var arr = new Array();
function addFUControl() {
var visible = $('input[type=file]').filter(function () {
return !($(this).css('visibility') == 'hidden' || $(this).css('display') == 'none');
}).length;
if (visible <= 1) {
for (var i = 0; i <= 4; i++) {
AddFileUpload();
}
}
else {
}
}
function AddFileUpload() {
var div = document.createElement('DIV');
div.innerHTML = '<input id="file_' + counter + '" name = "file' + counter +
'" type="file" Class = "fileUploadCntrl" />';
document.getElementById("FileUploadContainer").appendChild(div);
arr[counter] = document.getElementsByName("file" + counter);
counter++;
}
function FileUploadClick() {
$find('<%= modeloPopUpFileUpload.ClientID%>').hide();
debugger;
for (var i = 0; i < arr.length; i++) {
var previousFilePath = $(arr[i - 1]).val();
var filepath = $(arr[i]).val();
if (filepath != "")
{
if (filepath != previousFilePath) {
var Button = '<input id="btn_' + i + '" name = "btn' + i +
'" type="button" text="Delete" Class = "btn" style=width:80px; />';
$("#SelectedFilesManuplation").append(filepath);
$("#SelectedFilesManuplation").append(Button);
$("#SelectedFilesManuplation").append('<br>')
$("#file1Flag").val("1")
}
var a = arr[i];
$(a).hide();
}
else if (filepath == "")
{
var p2 = arr[i];
$(p2).remove();
}
These are my functions.
when User click on btn_AddFileUploadControl a popup get open and call the function addFUControl().
and the function create 5 dynamically FileUpload controls in the popup.
User select file and then press btn_OK. on btn_OK click it call the function FileUploadClick().
and this close the popup and display the filepath on my page.
hide the controls which have value.and remove those controls which don't have files.
MY PROBLEM IS THIS....
suddenly my user want to add more file.when he click on btn_AddFileUploadControl the popup get open and user select 1 more file.
and then he press btn_OK.
the files/controls which got hidden on btn_OK click last time.
are repeating again in the page.
for example.first time user select
1: c:/>test1.text
2: c:/>test2.text
these two files.and these file path displaying on page.
and when he click on again btn_AddFileUploadControl and from popup he select one more file
3: c:/>test3.text
when he press btn_OK then on my page it is displaying repetition.
like this one
c:/>test1.text
c:/>test2.text
c:/>test1.text
c:/>test2.text
c:/>test3.text
but i dont want this.
i want to show
c:/>test1.text
c:/>test2.text
c:/>test3.text
please help me in this problem.