If a download is to be started at the same time as a submit, the submit must first be intercepted and a download initiated.
<button
type="submit"
class="w-100 btn btn-dark rounded-0"
data-download="/download/file.pdf">
Button-Text
</button>
window.addEventListener("load", () => {
const fid = "#download-form";
const cr_form = document.querySelector(fid);
const cr_submitForm = document.querySelector(fid + " button[type=submit]");
if (cr_form != null) cr_form.addEventListener("submit", function(e) {
/* intercept submit: */
e.preventDefault();
/* Prepare a cheated auto-download: */
var element = document.createElement('a');
element.href = cr_submitForm.dataset.download;
/* regex, to have just the filename: */
element.download = /[^/]*$/.exec(cr_submitForm.dataset.download)[0];
cr_form.appendChild(element);
/* imitate a click: */
element.click();
/* and tidy up afterwards: */
cr_form.removeChild(element);
/* execute actual submit (via form post/get): */
$(this).submit();
})
});