I have a requirement to only have 1 attachment per document, but that the user
can change the attachment. I figured that using the delete method described to
only delete the existing attachment if a new one is being uploaded was a good
plan. I have the following JavaScript in the onSubmit to detect if we are
uploading a new attachment, and to write to a field that effectively deletes
the existing attachment. However, you have to click on the save button twice
for it to work. Any clever refinement ideas?
var newfile = document.forms[0].NewFile.value;
var del;
if (newfile =="") {
del = "";
} else {
start = newfile.lastIndexOf("\\") + 1;
end = newfile.length;
file_picname = newfile.slice(start,end);
del = '<input type="checkbox" name="%%Detach" CHECKED
value="'+file_picname+'">'+file_picname;
alert (del);
}
document.forms[0].DeleteAttachments.value = del
I have a requirement to only have 1 attachment per document, but that the user can change the attachment. I figured that using the delete method described to only delete the existing attachment if a new one is being uploaded was a good plan. I have the following JavaScript in the onSubmit to detect if we are uploading a new attachment, and to write to a field that effectively deletes the existing attachment. However, you have to click on the save button twice for it to work. Any clever refinement ideas?
var newfile = document.forms[0].NewFile.value; var del; if (newfile =="") { del = ""; } else { start = newfile.lastIndexOf("\\") + 1; end = newfile.length; file_picname = newfile.slice(start,end);
del = '<input type="checkbox" name="%%Detach" CHECKED value="'+file_picname+'">'+file_picname; alert (del); } document.forms[0].DeleteAttachments.value = del
Caroline