Skip to content

Instantly share code, notes, and snippets.

@LaxusCroco
Created November 27, 2023 10:48
Show Gist options
  • Save LaxusCroco/3ad3216e3f79f4d428c7da20f1e3345c to your computer and use it in GitHub Desktop.
Save LaxusCroco/3ad3216e3f79f4d428c7da20f1e3345c to your computer and use it in GitHub Desktop.
Display the uploaded Media file name with global macros of JetFormBuilder. Replace s_cv with the Media field name and uploaded_cv with an element ID, under which the Media field name should be shown
<script>
document.addEventListener('DOMContentLoaded', function () {
const fileInput = document.querySelector('#s_cv');
const outputPara = document.querySelector('#uploaded_cv');
fileInput.addEventListener('change', function () {
if (this.files.length > 0) {
let fileNames = Array.from(this.files).map(file => file.name).join(', ');
outputPara.innerHTML = '<b>Uploaded CVs:</b> ' + fileNames;
} else {
outputPara.innerHTML = 'No files selected';
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment