Hypeunulley
New Member
I want to remove a hidden input when a 'Remove' button or in other words the delete function is called, but problem is that with code below it does not remove the input, how can I get the correct input to be removed depending on the file name which is removed? Below is the code where it removes the correct file name but does not remove the hidden input (For testing I changed it to text input):\[code\] function stopImageUpload(success, imageID, imagefilename){ var result = ''; imagecounter++; if (success == 1){ result = '<span class="imagemsg'+imagecounter+'">The file was uploaded successfully</span>'; $('.hiddenimg').eq(window.lastUploadImageIndex).append('<input type="hidden" name="imgid[]" id="'+imageID+'" value="' + imageID + '" />'); $('.listImage').eq(window.lastUploadImageIndex).append('<div>' + htmlEncode(imagefilename) + '<button type="button" class="deletefileimage" data-imageID="'+imageID+'" data-image_file_name="' + imagefilename + '">Remove</button><br/><hr/></div>'); } var _imagecounter = imagecounter; $('.listImage').eq(window.lastUploadImageIndex).find(".deletefileimage").on("click", function(event) { jQuery.ajax("deleteimage.php?imagefilename=" + $(this).attr('data-image_file_name')).done(function(data) { $(".imagemsg" + _imagecounter).html(data); }); $(this).parent().remove(); $(".hiddenimg").parent().remove(); }); return true; }\[/code\]Below is the file input form:\[code\]var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target_image' onsubmit='return imageClickHandler(this);' class='imageuploadform' >" + "<p class='imagef1_upload_form'><label>" + "Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" + "<input type='submit' name='submitImageBtn' class='sbtnimage' value='http://stackoverflow.com/questions/14492704/Upload' /></label>" + "<input type='hidden' class='numimage' name='numimage' value='" + GetFormImageCount() + "' />" +</p>"</p><p class='imagemsg'></p><p class='listImage'></p>" +"<iframe class='upload_target_image' name='upload_target_image' src='http://stackoverflow.com/' style='width:0px;height:0px;border:0px;solid;#fff;'></iframe></form>"); \[/code\]The hidden input is placed in a div in another form and the reason it is in another form is because the form above will be nested into the form below and if I included the hidden input in above form, then I will have problem using $_POST to post the values from the hidden input in a nested form:\[code\]<form id="form" action="" method="post"><div class='hiddenimg'></div></form>\[/code\]