src/main/resources/static/js/viewController.js
/**
 * - LOAD ALL INPUTS-FILE AND ADD A CHANGE LISTENER
 */
- LOAD ALL INPUTS-FILE AND ADD A CHANGE LISTENER
- LOAD ALL INPUTS - FILE AND ADD A CHANGE LISTENER
function loadInputFiles()
{
    const inputsFile = document.querySelectorAll("input[type=file]");
    for(const inputFile of inputsFile)
    {
        inputFile.addEventListener('change', function()
        {
            const labelInput = this.labels[0];
            const currentFiles = this.files;
            if(currentFiles.length > 1)
            {
                labelInput.innerText = currentFiles.length + " arquivos selecionados";
            }
            else if(currentFiles.length == 0)
            {
                labelInput.innerText = "Clique aqui para selecionar";
            }
            else
            {
                labelInput.innerText = currentFiles[0].name;
            }
        });
    }
}
function loadInputFiles ( ) { const inputsFile = document . querySelectorAll ( "input[type=file]" ) ; for ( const inputFile of inputsFile ) { inputFile . addEventListener ( 'change' , function ( ) { const labelInput = this . labels [ 0 ] ; const currentFiles = this . files ; if ( currentFiles . length > 1 ) { labelInput . innerText = currentFiles . length + " arquivos selecionados" ; } else if ( currentFiles . length == 0 ) { labelInput . innerText = "Clique aqui para selecionar" ; } else { labelInput . innerText = currentFiles [ 0 ] . name ; } } ) ; } }
- LOAD ALL INPUTS-FILE AND ADD A CHANGE LISTENER
- LOAD ALL INPUTS - FILE AND ADD A CHANGE LISTENER
// GET INPUT-FILE ELEMENTS // ITERATE OVER EACH INPUT-FILE // RETURNS ONLY AN INPUT-LABEL BINDED AN INPUT-FILE // RETURNS A FILE-LIST WITH SELECTED FILES IN INPUT-FILE